foto aleatoria::servidor1 min read

Este es el codigo integro del webservice Picture. Este codigo no es muy genereico, de hecho esta bastante casado al modelo de galerie. Pero para cualquier cosa, contactenme.



require_once("nusoap/nusoap.php");
$SETTINGS = array(
"patern" => "s.+.jpg",
"base_dir" => "../fotos/albums/",
"url_start_dir" => "/fotos/albums/",
//a partir de base_dir deberan estar todos los folders de galerias
);

$soap_action = "http://".$_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"];

//generamos el ws
$s = new soap_server();
$s->debug_flag = false;
$s->configureWSDL("Picture","urn:b3co");
$s->wsdl->schemaTargetNamespace = "urn:b3co";

$s->wsdl->addComplexType(
'PictureData',
'complexType',
'struct',
'all',
'',
array( 'galerie_name' => array('name' => 'galerie_name', 'type' => 'xsd:string'),
'galerie_url' => array('name' => 'galerie_url', 'type' => 'xsd:string'),
'picture_page' => array('name' => 'picture_page', 'type' => 'xsd:string'),
'picture_url' => array('name' => 'picture_url', 'type' => 'xsd:string'))
);

$s->register('randomPicture',array('nada'=>'xsd:string'),array('return'=>'PictureData'),"urn:b3co",$soap_action);


function randomPicture($params){
global $SETTINGS;
$fotos = array();
if(!isset($SETTINGS["pattern"])){
$SETTINGS["pattern"] = "";
}
$d = dir($SETTINGS["base_dir"]);
while($d1 = $d->read()){
if($d1 != "." && $d1 != ".." && is_dir($SETTINGS["base_dir"].$d1)){
$di = dir($SETTINGS["base_dir"].$d1);
while($f = $di->read()){
if(ereg($SETTINGS["patern"],$f)){
ereg("([0-9]{1,3})",$f,$regs);
$num = $regs[1];
$fotos[count($fotos)] = array(
"galerie_name" => $d1,
"galerie_url" => "http://".$_SERVER["SERVER_NAME"].$SETTINGS["url_start_dir"].$d1,
"picture_page" => "http://".$_SERVER["SERVER_NAME"].$SETTINGS["url_start_dir"].$d1."/page_".$num.".html",
"picture_url" => "http://".$_SERVER["SERVER_NAME"].$SETTINGS["url_start_dir"].$d1."/".$f,
);
}
}
}
}
$rand = rand(0,count($fotos)-1);
return $fotos[$rand];
// return array(count($fotos),1,1);
}

$s->service($HTTP_RAW_POST_DATA);

Leave a Reply

Your email address will not be published. Required fields are marked *