<?php
/**
*
* @name Pindorama Core Configuration
* @version 0.1
* @author Guilherme Capilé <hide@address.com>
*
*/
global $arg, $param;
/**
*
* @name pin_read_http
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @return Retorna o Conteudo
*/
function pin_read_http ( $xh, $req )
{
$remote_file = "http:".$req;
$contents = file_get_contents($remote_file);
return $contents;
}
/**
*
* @name pin_read_odbc
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arg
* @global $param
*
* @see pin_save_file()
* @see pin_xml_array()
* @see pin_xsl_error()
* @see pin_copy_xpath()
*
* @return
*/
function pin_read_odbc ( $xh, $req )
{
global $c, $arg, $param;
if (preg_match("/^\/?([^\?\#]+)(\?[^\#]+)?(\#[^\.]+)?(\..+)?/", $req, $matches)) {
$scriptname = $matches[1];
$search = substr($matches[2], 1);;
$id = substr($matches[3], 1);
$el = substr($matches[4], 1);
$qs = array();
$i = 0;
foreach (explode("&", $search) as $tmp) {
if (preg_match("/([^\=]+)\=([^\=]+)/", $tmp, $matches)) {
$qs[$matches[1]] = $matches[2];
$qss[$i] = '$'.$matches[1];
$qsr[$i] = $matches[2];
}
}
} else {
$scriptname = preg_replace("/^\//", "", $req);
}
$cachefile = $c["base"]."/var/sql/".$scriptname.".xml";
if (is_file($cachefile) && ((time() - filemtime($cachefile)) < 60 )) {
// mostra o cache
$str = file_get_contents($cachefile);
} else {
$sqlfile = $c["base"]."/etc/sql/".$scriptname.".sql";
$metafile = $c["base"]."/etc/sql/".$scriptname.".xml";
if (@is_file($sqlfile)) {
$sql = str_replace($qss, $qsr, file_get_contents($sqlfile));
} else {
return $arg["empty"];
}
if (@is_file($metafile)) {
$meta = str_replace('$date', $param["date"], file_get_contents($metafile));
} else {
$meta = "<meta><date type=\"modified\">{$param['date']}</date></meta>";
}
$dsn = $c["sql_dsn"];
$database = $c["sql_database"];
$user = $c["sql_user"];
$password = $c["sql_password"];
$names = "";
$db = odbc_connect ($dsn, $user, $password);
if (odbc_error()) {
pin_xsl_error(odbc_errormsg($db));
exit();
}
if ($db > 0) {
$rs = odbc_exec($db, $sql);
// gets the collumn names - lowercase
$i = 0;
$cols = odbc_num_fields($rs);
while ($i < $cols) {
$i++;
$name[] = strtolower(odbc_field_name($rs, $i));
}
for ($i = 1; odbc_fetch_into($rs,$temp, $i); $i++) {
$j = 0;
$unrow = "";
foreach ($temp as $tmp) {
if ($j == 0) {
$unrow["ref"]["@id"] = $tmp;
$j++;
} else {
$unrow["ref"][$name[$j++]] = $tmp;
}
}
$resultado[$i] = $unrow;
}
odbc_close($db);
}
if (!is_array($resultado)) {
//exit ("A consulta não retornou nenhum resultado");
return $arg["empty"];
}
$res = pin_xml_array($resultado, FALSE);
$str = <<<FIM
<?xml version="1.0" encoding="iso-8859-1"?>
<xpml version="0.1" scheme="index">
$meta
<resource name="{$scriptname}" type="dataset">
$res
</resource>
</xpml>
FIM;
pin_save_file($cachefile, $str);
}
if ($id != "" && $el != "") {
$str = pin_copy_xpath("/xpml/resource//*[@id = '$id']/$el", $cachefile, TRUE);
} else if ($id != "") {
$str = pin_copy_xpath("/xpml/resource//*[@id = '$id']", $cachefile, TRUE);
}
return $str;
}
/**
*
* @name pin_read_mysql
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arg
* @global $param
*
* @see pin_save_file()
* @see pin_xml_array()
* @see pin_xsl_error()
* @see pin_copy_xpath()
*
* @return
*/
function pin_read_mysql($xh, $req)
{
global $c, $arg, $param;
if (preg_match("/^\/?([^\?\#]+)(\?[^\#]+)?(\#[^\.]+)?(\..+)?/", $req, $matches)) {
$scriptname = $matches[1];
$search = substr($matches[2], 1);;
$id = substr($matches[3], 1);
$el = substr($matches[4], 1);
$qs = array();
$i = 0;
foreach (explode("&", $search) as $tmp) {
if (preg_match("/([^\=]+)\=([^\=]+)/", $tmp, $matches)) {
$qs[$matches[1]] = $matches[2];
$qss[$i] = '$'.$matches[1];
$qsr[$i] = $matches[2];
}
}
} else {
$scriptname = preg_replace("/^\//", "", $req);
}
$cachefile = $c["base"]."/var/sql/".$scriptname.".xml";
$cachetime = ($c["sql_cache_timeout"] != "")?($c["sql_cache_timeout"]):(60);
if (is_file($cachefile) && ((time() - filemtime($cachefile)) < $cachetime )) {
// mostra o cache
$str = file_get_contents($cachefile);
} else {
$sqlfile = $c["base"]."/etc/sql/".$scriptname.".sql";
$metafile = $c["base"]."/etc/sql/".$scriptname.".xml";
if (@is_file($sqlfile)) {
$sql = str_replace($qss, $qsr, file_get_contents($sqlfile));
} else {
return $arg["empty"];
}
if (@is_file($metafile)) {
$meta = str_replace('$date', $param["date"], file_get_contents($metafile));
} else {
$meta = "<meta><date type=\"modified\">{$param['date']}</date></meta>";
}
$server = $c["sql_server"];
$database = $c["sql_database"];
$user = $c["sql_user"];
$password = $c["sql_password"];
$names = "";
if ($param["conn"] < 1) {
$param["conn"] = @mysql_connect ( $server, $user, $password );
}
if (mysql_error() != "") {
pin_xsl_error(mysql_error());
exit();
}
if ($database != "") {
mysql_select_db($database, $param["conn"]);
}
if (mysql_error() != "") {
pin_xsl_error(mysql_error());
exit();
}
if ($param["conn"] > 0) {
$rs = @mysql_query($sql, $param["conn"]);
$result = @mysql_num_rows ($rs);
if (!$rs || mysql_error() != "") {
pin_xsl_error(mysql_error().$sql);
exit();
}
$i = 0;
if ($result > 0) {
while ($row = mysql_fetch_assoc($rs)) {
$tmp = array();
$tmp["ref"]["@id"]= array_shift($row);
$tmp["ref"] += $row;
$resultado[]=$tmp;
}
}
@mysql_free_result($param["conn"]);
}
if (!is_array($resultado)) {
//exit ("A consulta não retornou nenhum resultado");
return $arg["empty"];
}
$res = pin_xml_array($resultado, FALSE);
$str = <<<FIM
<?xml version="1.0" encoding="iso-8859-1"?>
<xpml version="0.1" scheme="index">
$meta
<resource name="{$scriptname}" type="dataset">
$res
</resource>
</xpml>
FIM;
pin_save_file($cachefile, $str);
}
if ($id != "" && $el != "") {
$str = pin_copy_xpath("/xpml/resource//*[@id = '$id']/$el", $cachefile, TRUE);
} else if ($id != "") {
$str = pin_copy_xpath("/xpml/resource//*[@id = '$id']", $cachefile, TRUE);
}
$str = (trim($str) == "" || trim($str) == $c["xmlpi"])?($arg["empty"]):($str);
return $str;
}
/**
*
* @name pin_read_tmp
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arg
*
* @return
*/
function pin_read_tmp ( $xh, $req )
{
global $c, $arg;
if (preg_match("/^\/?([^\:]+)/", $req, $matches)) {
$req = $matches[1];
$xmlfile = $c["users"]."tmp.".$matches[1];
if (is_file($xmlfile)) {
$contents = file_get_contents($xmlfile);
} else {
$contents = $arg["empty"];
}
} else {
$contents = $arg["empty"];
}
return $contents;
}
/**
*
* @name pin_read_index
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
* @global $param
*
*
* @see pin_read_dir()
*
* @return Retorna o Conteudo
*/
function pin_read_index ( $xh, $req )
{
global $c, $arg, $param;
if (preg_match("/^\/?([^\.]+)\.([^\.]+)\.(.+)$/", $req, $matches) && is_file($c["index"].$matches[1]."/".$matches[2].".".$matches[3].".xml")) {
// reads the copy: the result is stored in a separate folder
// $req = [index].[@id].[string unique key -> date-user]
$xmlfile = $c["index"].$matches[1]."/".$matches[2].".".$matches[3].".xml";
$contents = file_get_contents($xmlfile);
} else if (preg_match("/^\/?([^\#\:]+)[\#\:](.+)/", $req, $matches)) {
// reads the node.element specified after '#'
$req = $matches[1];
$id = $matches[2];
$xmlfile = $c["index"].$req.".xml";
$binfile = $c["index"].$req."/".$id;
if (is_file($binfile)) {
$contents = file_get_contents($binfile);
} else if (is_file($xmlfile)) {
$xp = "";
if ($id == "latest") {
$xp = "/xpml/resource//*[@id = (/xpml/resource/@next -1)]";
} else if (preg_match("/^([^\.]+)(\..+)/", $id, $matches)) {
$xp = "/xpml/resource//*[@id = '{$matches[1]}']".str_replace(".", "/", $matches[2]);
} else {
$xp = "/xpml/resource//*[@id = '$id']";
}
$contents = pin_copy_xpath($xp, $xmlfile);
if ($contents == "") {
$contents = $arg["empty"];
} else {
$contents = $c["xmlpi"].$contents;
}
} else {
$contents = $arg["empty"];
}
} else {
// reads entire index
$xmlfile = $c["index"].$req.".xml";
$xmlmainfile = $c["index"].preg_replace("/\..*$/", "", $req).".xml";
if (is_file($xmlfile)) {
$contents = file_get_contents($xmlfile);
} else if (is_file($xmlmainfile)) {
$contents = file_get_contents($xmlmainfile);
} else {
$contents = $arg["empty"];
}
}
$filesdir = preg_replace("/\..*$/", "", preg_replace("/^\//", "", $req));
$files = pin_read_dir($c["index"].$filesdir, "name", "*.xml");
$param["versions"] = "";
if (is_array($files)) {
foreach ($files as $file) {
$param["versions"] .= "index:".$filesdir.".".substr($file["name"], 0, strlen($file["name"]) -4)." ";
}
}
return $contents;
}
/**
*
* @name pin_write_index
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
* @global $param
* @global $l
*
* @see pin_read_index()
* @see pin_check_permission()
* @see pin_copy_xpath()
* @see pin_save_file()
* @see pin_send_message()
* @see pin_xsl_process()
*
* @return Retorna o Conteudo
*/
function pin_write_index ( $xh, $req )
{
global $c, $arg, $param, $l;
if (preg_match("/^\/?([^\.]+)\.([^\.]+)\.(.+)$/", $req, $matches)) {
// save as a copy: writes the result (single ref) in a separate folder
// $req = [index].[@id].[string unique key -> date-user]
$xmlfile = $c["index"].$matches[1]."/".$matches[2].".".$matches[3].".xml";
if (!is_file($xmlfile)) {
// creates the copy-file if it doesn't exist
$contents = str_replace($c["xmlpi"], "", pin_read_index( $xh, $matches[1]."#".$matches[2] ));
if ($contents == $arg["empty"] || trim($contents) == "") {
$contents = "<ref id=\"{$matches[2]}\">0</ref>";
}
$meta = pin_copy_xpath("/xpml/meta/*[name()!='rights']", $c["index"].$matches[1].".xml");
$contents = $c["xmlpi"]."<xpml><meta>$meta</meta><resource name=\"{$matches[1]}\" type=\"dataset\">".$contents."</resource></xpml>";
pin_save_file($xmlfile, $contents);
}
} else if (preg_match("/^([^\#]+)\#(.*)/", $req, $matches)){
$xmlfile = $c["index"].$matches[1].".xml";
$indexfile = $matches[1];
} else {
$xmlfile = $c["index"].$req.".xml";
$indexfile = $req;
}
if (!is_file($xmlfile)) {
return false;
}
if (!pin_check_permission($xmlfile, "write", $param["auth-user"])) {
pin_send_message("{$l['msg']['index']} $req {$l['msg']['failure_ending2']}");
return false;
}
if ($arg["index_update"] != "") {
$result = pin_xsl_process ($xmlfile, $c["stylesheets"]."dav/index_update.xsl", $xmlfile);
// file uploads
//$checkfiles = pin_read_xpath("/xpml/resource//*/@ref-src", $xmlfile);
//if (count($_FILES) > 0 && count($checkfiles) > 0) {
// foreach ($_FILES as $k=>$v) {
// if (is_uploaded_file($v["tmp_name"])) {
// $filename = preg_replace("/[^0-9]/", "", $param["date"]);
// if (count($_FILES) > 1) {
// $filename .= "-".preg_replace("/^.*\-/", "", $k);
// }
// $filename .= "-".$v["name"];
// $filecheck = "index:".$indexfile.":".$filename;
// if (in_array($filecheck, $checkfiles)) {
// $dir = $c["index"].$indexfile."/";
// if (!is_dir($dir)) {
// pin_make_pathtofile($dir.$filename);
// }
// move_uploaded_file($v["tmp_name"], $dir.$filename);
// }
// }
// }
//}
//if (count($checkfiles) > 0 && is_dir($c["index"].$indexfile."/")) {
// $files = read_dir($c["index"].$indexfile."/", "fullname name");
// foreach ($files as $file) {
// $filecheck = "index:".$indexfile.":".$file["name"];
// if (!in_array($filecheck, $checkfiles)) {
// @unlink($file["fullname"]);
// }
// }
//}
//end file uploads
} else {
$result = pin_xsl_process ($xmlfile, $c["stylesheets"]."dav/dav_update.xsl", $xmlfile);
}
if (!$result) {
//logar erro
pin_send_message("{$l['msg']['index']} $req {$l['msg']['failure_ending2']}");
return false;
} else {
pin_send_message("{$l['msg']['index']} $req {$l['msg']['success_ending2']}");
return true;
}
}
/**
*
* @name pin_delete_index
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
* @global $param
*
* @see pin_check_permission()
* @see pin_send_message()
*
* @return Retorna o Conteudo
*/
function pin_delete_index ( $xh, $req )
{// only works for record copies
global $c, $arg, $param;
if (preg_match("/^\/?([^\.]+)\.([^\.]+)\.(.+)$/", $req, $matches)) {
// save as a copy: writes the result (single ref) in a separate folder
// $req = [index].[@id].[string unique key -> date-user]
$xmlfile = $c["index"].$matches[1]."/".$matches[2].".".$matches[3].".xml";
if (!pin_check_permission($xmlfile, "write", $param["auth-user"])) {
pin_send_message("{$l['msg']['index']} $req {$l['msg']['failure_ending2']}");
return false;
}
if (is_file($xmlfile) && @unlink($xmlfile)) {
return true;
}
}
return false;
}
/**
*
* @name pin_read_styleshets
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
*
* @return Retorna o Conteudo
*/
function pin_read_styleshets ( $xh, $req )
{
global $c, $arg;
$xmlfile = $c["stylesheets"].$req.".xml";
if (is_file($xmlfile)) {
$contents = file_get_contents($xmlfile);
} else {
$contents = $arg["empty"];
}
return $contents;
}
/**
*
* @name pin_read_content
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
*
* @return Retorna o Conteudo
*/
function pin_read_content ( $xh, $req )
{
global $c, $arg;
$xmlfile = $c["db"]."content/".$req.".xml";
if (is_file($xmlfile)) {
$contents = file_get_contents($xmlfile);
} else {
$contents = $arg["empty"];
}
return $contents;
}
/**
*
* @name pin_write_content
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arq
*
* @see pin_xsl_process()
*
* @return Retorna o Conteudo
*/
function pin_write_content ( $xh, $req )
{
global $c, $arg;
$xmlfile = $c["db"]."content/".$req.".xml";
if (is_file($xmlfile)) {
$result = pin_xsl_process ($xmlfile, $c["stylesheets"]."dav/dav_update.xsl", $xmlfile);
if ($result) {
echo "$xmlfile ok <br />";
}
}
}
/**
*
* @name pin_read_dtd
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
* @global $c
* @global $arq
*
* @return Retorna o Conteudo
*/
function pin_read_dtd ( $xh, $req )
{
global $c, $arg;
$xmlfile = $c["db"].$req.".dtd";
if (is_file($xmlfile)) {
$contents = file_get_contents($xmlfile);
} else {
$contents = "";
}
return $contents;
}
/**
*
* @name pin_read_db
* @deprecated le o banco de dados
*
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $param
*
* @global $c
* @global $arg
* @global $param
*
* @see pin_read_dir()
*
* @return Retorna o Conteudo
*/
function pin_read_db ( $xh, $req )
{
global $c, $arg, $param;
$xmlfile = $c["db"].$req.".xml";
$binfile = $c["db"].str_replace(":", "/", $req);
$xslfile = $c["components"]."db_parser.xsl";
if (preg_match("/^\/?([a-z0-9\-]*)?new/", $req, $matches)) {
$contents = file_get_contents($c["db"].$matches[1]."new.xml");
} else if (is_file($xmlfile)) {
//$contents = xsl_process($xmlfile, $xslfile);
$contents = file_get_contents($xmlfile);
} else if (is_file($binfile)) {
$contents = file_get_contents($binfile);
} else {
$contents = $arg["empty"];
}
if ($param["editing"]) {
$files = pin_read_dir($c["db"]."/", "name", $req.".*.xml");
}
$param["versions"] = "";
if (is_array($files)) {
foreach ($files as $file) {
$param["versions"] .= "db:".substr($file["name"], 0, strlen($file["name"]) -4)." ";
}
}
return $contents;
}
/**
*
* @name pin_write_db
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arq
* @global $param
* @global $l
*
* @see pin_xsl_process()
* @see pin_read_xpath()
* @see pin_make_pathtofile()
* @see pin_save_file()
* @see pin_read_dir()
* @see pin_write_db()
* @see pin_send_message()
* @see pin_redirect()
*
* @return Retorna o Conteudo
*/
function pin_write_db ( $xh, $req )
{
global $c, $arg, $param, $l;
$xmlfile = $c["db"].$req.".xml";
if (is_file($xmlfile)) {
$result = pin_xsl_process ($xmlfile, $c["stylesheets"]."dav/dav_update.xsl", $xmlfile);
if ($result) {
$checkfiles = pin_read_xpath("//resource[@type='binary']/resource-description/@ref-src", $xmlfile);
if (count($_FILES) > 0 && count($checkfiles) > 0) {
foreach ($_FILES as $k=>$v) {
if (is_uploaded_file($v["tmp_name"])) {
$filename = preg_replace("/[^0-9]/", "", $param["date"]);
if (count($_FILES) > 1) {
$filename .= "-".preg_replace("/^.*\-/", "", $k);
}
$filename .= "-".$v["name"];
$filecheck = "db:".$req.":".$filename;
if (in_array($filecheck, $checkfiles)) {
$dir = $c["db"].$req."/";
if (!is_dir($dir)) {
pin_make_pathtofile($dir.$filename);
}
move_uploaded_file($v["tmp_name"], $dir.$filename);
}
}
}
}
if (count($checkfiles) > 0 && is_dir($c["db"].$req."/")) {
$files = pin_read_dir($c["db"].$req."/", "fullname name");
foreach ($files as $file) {
$filecheck = "db:".$req.":".$file["name"];
if (!in_array($filecheck, $checkfiles)) {
@unlink($file["fullname"]);
}
}
}
//send_message($l["msg"]["fileinfo"]." db:$xmlref ".$l["msg"]["success_ending"]);
return true;
}
} else if (preg_match("/^\/?([a-z0-9\-]*)?new/", $req, $matches)) {
$xmlref = trim(file_get_contents($c["db"].$matches[1]."next"));
if ($xmlref != "" && copy($c["db"].$matches[1]."new.xml", $c["db"].$xmlref.".xml")) {
$next = substr($xmlref, 0, strpos($xmlref, "_n"))."_n".str_pad(((int)substr($xmlref, 5) + 1), 5, "0", STR_PAD_LEFT);
pin_save_file($c["db"].$matches[1]."next", $next);
$param["xpml-identifier"] = "db:$xmlref";
if (pin_write_db($xh, $xmlref)) {
pin_send_message("{$l['msg']['file']} db:$xmlref {$l['msg']['success_ending_new']}.");
pin_redirect ($param["script-name"]."?id=db:".$xmlref);
exit();
}
} else {
return false;
}
} else if (preg_match("/^([^\.]+)\.(.+)$/", $req, $matches) && is_file($c["db"].$matches[1].".xml") && !is_file($c["db"].$req.".xml")) {
// salvar como cópia
if (copy($c["db"].$matches[1].".xml", $c["db"].$req.".xml")) {
$param["update-rights"] = "<rights/>";
$param["xpml-identifier"] = "db:$req";
if (pin_write_db($xh, $req)) {
pin_send_message("{$l['msg']['file']} db:$xmlref {$l['msg']['copy_success_ending']}.");
pin_redirect ($param["script-name"]."?id=db:".$req);
exit();
} else {
exit("Erro Função : pin_redirect");
}
} else {
return false;
}
}
}
/**
*
* @name pin_delete_db
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arq
* @global $param
*
* @see pin_read_dir()
*
* @return
*/
function pin_delete_db ( $xh, $req )
{
global $c, $arg, $param;
$xmlfile = $c["db"].$req.".xml";
if (is_file($xmlfile)) {
/*$toupdate = read_xpath(array("//*[@xpml-import != '']/@xpml-import-prefix", "//*[@xpml-import != '']/@xpml-import"), $xmlfile);
for ($i = 0; $i < count($toupdate[0]); $i++) {
$xmlfile = "";
if ($toupdate[0][$i] != "") {
$xmlfile = $toupdate[0][$i].":";
}
$xmlfile .= $toupdate[1][$i];
$result = xsl_schemes_delete ($xmlfile, $toupdate[0][$i], $toupdate[1][$i]);
if (!$result) {
exit();//echo $xmlfile."ok<br />";
}
}*/
$files = pin_read_dir($c["db"]."/", "fullname is_dir", $req."*");
if (is_array($files)) {
foreach ($files as $file) {
if ($file["is_dir"] == 1) {
$subfiles = pin_read_dir($file["fullname"], "fullname");
if (is_array($subfiles)) {
foreach ($subfiles as $subfile) {
@unlink($subfile["fullname"]);
}
}
@rmdir($file["fullname"]);
} else {
@unlink($file["fullname"]);
}
}
@rmdir($c["db"].$req."/");
}
@unlink($xmlfile);
return true;
} else {
return false;
}
}
/**
*
* @name pin_read_php
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arq
*
*
* @return Retorna o Conteudo
*/
function pin_read_php ( $xh, $req )
{
global $c, $arg;
if (preg_match("/^\/*(@?[a-z_]*)[\:\#]?(.*)$/i", $req, $matches)) {
$function = $matches[1];
$str = str_replace(",", "','", $matches[2]);
if (function_exists($function)) {
$eval = '$contents = '.$function."('".$str."');";
eval($eval);
} else if (function_exists("pin_".$function)) {
// Mantendo compatibilidade com funcoes sem o 'PIN_'
$eval = '$contents = pin_'.$function."('".$str."');";
eval($eval);
}
} else {
$contents = $arg["empty"];
}
return $contents;
}
/**
*
* @name pin_read_phpxml
* @deprecated
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $req
*
* @global $c
* @global $arq
*
*
* @return Retorna o Conteudo
*/
function pin_read_phpxml ( $xh, $req )
{
global $c, $arg;
if (preg_match("/^\/*(@?[a-z_]*)\:(.*)$/i", $req, $matches)) {
$function = $matches[1];
$str = str_replace(",", "','", $matches[2]);
if (function_exists($function)) {
$eval = '$contents = '.$function."('".$str."');";
eval($eval);
} else if (function_exists("pin_".$function)) {
// Mantendo compatibilidade com funcoes sem o 'pin_'
$eval = '$contents = pin_'.$function."('".$str."');";
eval($eval);
}
} else {
$contents = "";
}
return $c["xmlpi"]."<xpml>$contents</xpml>";
}
/**
*
* @name pin_read_include
* @deprecated le o include
*
* @version 0.11
*
* @author Guilherme Capilé <hide@address.com>
*
* @param $xh
* @param $param
*
* @global $c
* @global $arg
*
*
* @return Retorna o Conteudo
*/
function pin_read_include ( $xh, $req )
{
global $c, $arg;
if (!preg_match("/\:|\;|\.\./", $req)) {
$xmlfile = $c["includes"].$req;
if (is_file($xmlfile)) {
$contents = $c["xmlpi"]."<!--".file_get_contents($xmlfile)."--><a/>";
} else {
$contents = $arg["empty"];
}
} else {
$contents = $arg["empty"];
}
return $contents;
}
function pin_read_arg ($xh, $req)
{
global $c, $arg;
if (preg_match("/^\/*(@?[a-z_]*)$/i", $req, $matches)) {
$var = $matches[1];
return $arg[$var];
} else {
return $c["xmlpi"]."<xpml>$contents</xpml>";
}
}
?>