<?php
/**
* verzia 10.0
*/
header("content-type: text/xml; charset=utf-8");
if (isset($_GET['wsdl'])) {
require_once 'generator_wsdl.php';
} else {
require_once 'config.php';
require_once 'toArray.php';
function impl($arr) {
$ret = '';
if (!is_array($arr)) {
return $arr;
}
foreach(array_keys($arr) as $key) {
if (is_array($arr[$key])) {
$ret .= $key.' = + + + + + + + + + + + + + + +'."\n"
.impl($arr[$key])
.'- - - - - - - - - - - - - - - - - - -'."\n";
} else {
$ret .= $key.' = '.$arr[$key]."\n";
}
}
return $ret;
}
function modifyNodes($arr) {
$ret = array();
foreach(array_keys($arr) as $key) {
$pieces = explode(':', $key);
$new_key = $pieces[count($pieces)-1];
if (is_array($arr[$key])) {
$ret[$new_key] = modifyNodes($arr[$key]);
} else {
$ret[$new_key] = $arr[$key];
}
}
return $ret;
}
function prepare_str($str) {
global $ezin_cfg;
$ret = strip_tags($str);
$ret = htmlspecialchars($ret);
$ret = str_replace(array('%'),array('%'), $ret);
//$ret = preg_replace('/&(\S)+;/',' ',$ret);
$ret = iconv($ezin_cfg['encoding'], 'UTF-8', $ret);
return $ret;
}
$postdata = file_get_contents("php://input");
//$soap_arr = xml2ary($HTTP_RAW_POST_DATA);
$soap_arr = xml2ary($postdata);
$soap_arr2 = modifyNodes($soap_arr);
/*
$str = '';
$str .= impl($_POST);
$str .= "-----------------------------------\n";
$str .= impl($_GET);
$str .= "-----------------------------------\n";
$str .= impl($_SERVER);
$str .= "-----------------------------------\n";
$str .= $HTTP_RAW_POST_DATA."\n";
$str .= "-----------------------------------\n";
$str .= impl(xml2ary($HTTP_RAW_POST_DATA));
$fp = fopen('log.txt', 'w+');
fwrite($fp, $str);
fclose($fp);
*/
if (!is_array($soap_arr2['Envelope']['_c']['Body']['_c'])) {
Exit();
}
$soap_action = array_keys($soap_arr2['Envelope']['_c']['Body']['_c']);
$soap_action = $soap_action[0];
$soap_out = '';
$soap_out .= '<| "<" |>?xml version="1.0" encoding="utf-8" ?'.'<| ">\n" |>';
switch($soap_action) {
case 'GetLatestHeadLinesByCategory':
$nCategoryID = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByCategory']['_c']['nCategoryID']['_v'];
$nRowIndex = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByCategory']['_c']['nRowIndex']['_v'];
$nCount = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByCategory']['_c']['nCount']['_v'];
$soap_out .= '
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLatestHeadLinesByCategoryResponse xmlns="'.$namespace.'">
<GetLatestHeadLinesByCategory>
';
$articles = ezin_get_article_list(intval($nCategoryID),0,0);
$last_article = ($nCount == 0) ? count($articles) : $nRowIndex + $nCount - 1;
$last_article = ($last_article > count($articles)) ? count($articles) : $last_article;
for ($a = $nRowIndex; $a <= $last_article; $a++) {
// $nRowIndex je cislovany od 1, preto sa posuva
$b = $a - 1;
$soap_out .= '
<Article>
<ID>'.$articles[$b]['article_id'].'</ID>
<ID_Author>'.$articles[$b]['article_author_id'].'</ID_Author>
<ID_Category>'.$articles[$b]['article_section_id'].'</ID_Category>
<ReleaseDate>'.substr(date('c',$articles[$b]['article_timestamp']),0,19).'</ReleaseDate>
<Title>'.prepare_str($articles[$b]['article_title']).'</Title>
</Article>
';
}
$soap_out .= '
</GetLatestHeadLinesByCategory>
</GetLatestHeadLinesByCategoryResponse>
</soap:Body>
</soap:Envelope>
';
break;
case 'GetLatestHeadLinesByAuthor':
$nAuthorID = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByAuthor']['_c']['nAuthorID']['_v'];
$nRowIndex = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByAuthor']['_c']['nRowIndex']['_v'];
$nCount = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLinesByAuthor']['_c']['nCount']['_v'];
$soap_out .='
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLatestHeadLinesByAuthorResponse xmlns="'.$namespace.'">
<GetLatestHeadLinesByAuthorResult>
';
$articles = ezin_get_article_list(0,intval($nAuthorID),0);
$last_article = ($nCount == 0) ? count($articles) : $nRowIndex + $nCount - 1;
$last_article = ($last_article > count($articles)) ? count($articles) : $last_article;
for ($a = $nRowIndex; $a <= $last_article; $a++) {
// $nRowIndex je cislovany od 1, preto sa posuva
$b = $a - 1;
$soap_out .= '
<Article>
<ID>'.$articles[$b]['article_id'].'</ID>
<ID_Author>'.$articles[$b]['article_author_id'].'</ID_Author>
<ID_Category>'.$articles[$b]['article_section_id'].'</ID_Category>
<ReleaseDate>'.substr(date('c',$articles[$b]['article_timestamp']),0,19).'</ReleaseDate>
<Title>'.prepare_str($articles[$b]['article_title']).'</Title>
</Article>
';
}
$soap_out .= '
</GetLatestHeadLinesByAuthorResult>
</GetLatestHeadLinesByAuthorResponse>
</soap:Body>
</soap:Envelope>
';
break;
case 'GetLatestHeadLines':
$nRowIndex = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLines']['_c']['nRowIndex']['_v'];
$nCount = $soap_arr2['Envelope']['_c']['Body']['_c']['GetLatestHeadLines']['_c']['nCount']['_v'];
$soap_out .= '
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLatestHeadLinesResponse xmlns="'.$namespace.'">
<GetLatestHeadLinesResult>
';
$articles = ezin_get_article_list(0,0,0);
$last_article = ($nCount == 0) ? count($articles) : $nRowIndex + $nCount - 1;
$last_article = ($last_article > count($articles)) ? count($articles) : $last_article;
for ($a = $nRowIndex; $a <= $last_article; $a++) {
// $nRowIndex je cislovany od 1, preto sa posuva
$b = $a - 1;
$soap_out .= '
<Article>
<ID>'.$articles[$b]['article_id'].'</ID>
<ID_Author>'.$articles[$b]['article_author_id'].'</ID_Author>
<ID_Category>'.$articles[$b]['article_section_id'].'</ID_Category>
<ReleaseDate>'.substr(date('c',$articles[$b]['article_timestamp']),0,19).'</ReleaseDate>
<Title>'.prepare_str($articles[$b]['article_title']).'</Title>
</Article>
';
}
$soap_out .= '
</GetLatestHeadLinesResult>
</GetLatestHeadLinesResponse>
</soap:Body>
</soap:Envelope>
';
break;
case 'GetAuthors':
$count = $soap_arr2['Envelope']['_c']['Body']['_c']['GetAuthors']['_c']['count']['_v'];
$authors = ezin_get_authors($count);
$soap_out .= '
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetAuthorsResponse xmlns="'.$namespace.'">
<GetAuthorsResult>
';
for ($a = 0; $a < count($authors); $a++) {
$names = explode(' ',$authors[$a]['name']);
$first_name = array_shift($names);
if (is_array($names)) {
$last_name = implode(' ', $names);
} else {
$last_name = $names;
}
$soap_out .= '
<Author>
<ID>'.$authors[$a]['id'].'</ID>
<FirstName>'.prepare_str($first_name).'</FirstName>
<LastName>'.prepare_str($last_name).'</LastName>
</Author>
';
}
$soap_out .= '
</GetAuthorsResult>
</GetAuthorsResponse>
</soap:Body>
</soap:Envelope>
';
break;
case 'GetArticle':
$id = $soap_arr2['Envelope']['_c']['Body']['_c']['GetArticle']['_c']['articleID']['_v'];
$article = ezin_get_article($id);
$soap_out .= '
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetArticleResponse xmlns="'.$namespace.'">
<GetArticleResult>
<ID>'.$article['article_id'].'</ID>
<ID_Author>'.$article['article_author_id'].'</ID_Author>
<ID_Category>'.$article['article_section_id'].'</ID_Category>
<ReleaseDate>'.substr(date('c',$articles[$b]['article_timestamp']),0,19).'</ReleaseDate>
<Title>'.prepare_str($article['article_title']).'</Title>
<Text><![CDATA['.prepare_str($article['article_bodytext']).']]></Text>
</GetArticleResult>
</GetArticleResponse>
</soap:Body>
</soap:Envelope>
';
break;
case 'GetCategories':
$soap_out .= '
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetCategoriesResponse xmlns="'.$namespace.'">
<GetCategoriesResult>
';
$sections = ezin_get_section_list();
for ($a = 1; $a < count($sections); $a++) {
$soap_out .= '
<Category>
<ID>'.$sections[$a]['section_id'].'</ID>
<CategoryName>'.prepare_str($sections[$a]['section_name']).'</CategoryName>
</Category>
';
}
$soap_out .= '
</GetCategoriesResult>
</GetCategoriesResponse>
</soap:Body>
</soap:Envelope>
';
break;
default:
break;
}
}
?>
Platon Group <platon@platon.sk> http://platon.sk/
|