|
From: <rd...@us...> - 2009-03-21 20:27:34
|
Revision: 1986
http://digir.svn.sourceforge.net/digir/?rev=1986&view=rev
Author: rdg
Date: 2009-03-21 20:27:22 +0000 (Sat, 21 Mar 2009)
Log Message:
-----------
Added new metadata field for entity type.
Modified Paths:
--------------
tapirlink/trunk/classes/TpEntity.php
tapirlink/trunk/classes/TpMetadataForm.php
tapirlink/trunk/classes/TpResourceMetadata.php
tapirlink/trunk/templates/TpMetadataForm.tmpl.php
Modified: tapirlink/trunk/classes/TpEntity.php
===================================================================
--- tapirlink/trunk/classes/TpEntity.php 2009-03-21 20:26:36 UTC (rev 1985)
+++ tapirlink/trunk/classes/TpEntity.php 2009-03-21 20:27:22 UTC (rev 1986)
@@ -31,6 +31,7 @@
class TpEntity extends TpBusinessObject
{
var $mIdentifier = '';
+ var $mType;
var $mNames;
var $mAcronym;
var $mLogoUrl;
@@ -53,8 +54,9 @@
} // end of member function TpEntity
- function LoadDefaults( )
+ function LoadDefaults( )
{
+ $this->SetType( 'organization' );
$this->AddName( '', '' );
$this->AddDescription( '', '' );
@@ -70,6 +72,8 @@
{
$this->mIdentifier = TpUtils::GetVar( $prefix.'_id', '' );
+ $this->mType = TpUtils::GetVar( $prefix.'_type', '' );
+
$this->LoadLangElementFromSession( $prefix.'_name', $this->mNames );
$this->mAcronym = TpUtils::GetVar( $prefix.'_acronym', '' );
@@ -171,6 +175,18 @@
} // end of member function SetIdentifier
+ function GetType( )
+ {
+ return $this->mType;
+
+ } // end of member function GetType
+
+ function SetType( $type )
+ {
+ $this->mType = $type;
+
+ } // end of member function SetType
+
function GetNames( )
{
return $this->mNames;
@@ -379,8 +395,15 @@
$indent1 = $offset.$indentWith;
$indent2 = $offset.$indentWith.$indentWith;
- $xml = TpUtils::OpenTag( '', 'entity', $offset );
+ $attrs = array();
+ if ( ! empty( $this->mType ) )
+ {
+ $attrs['type'] = $this->mType;
+ }
+
+ $xml = TpUtils::OpenTag( '', 'entity', $offset, $attrs );
+
$xml .= TpUtils::MakeTag( '', 'identifier', $this->mIdentifier, $indent1 );
foreach ( $this->mNames as $lang_string )
Modified: tapirlink/trunk/classes/TpMetadataForm.php
===================================================================
--- tapirlink/trunk/classes/TpMetadataForm.php 2009-03-21 20:26:36 UTC (rev 1985)
+++ tapirlink/trunk/classes/TpMetadataForm.php 2009-03-21 20:27:22 UTC (rev 1986)
@@ -283,6 +283,11 @@
'of a standard, just put the name or acronym or create '.
'some identifier.';
}
+ else if ( $labelId == 'entityType')
+ {
+ $label = 'Type';
+ $doc = 'Entity type (person or organization).';
+ }
else if ( $labelId == 'acronym')
{
$label = 'Acronym';
@@ -445,6 +450,11 @@
$options = array('data supplier' => 'Data Supplier',
'technical host' => 'Technical Host');
}
+ else if ( $id == 'entityType')
+ {
+ $options = array('organization' => 'Organization',
+ 'person' => 'Person');
+ }
else if ( $id == 'contactRoles')
{
$options = array('data administrator' => 'Data Administrator',
Modified: tapirlink/trunk/classes/TpResourceMetadata.php
===================================================================
--- tapirlink/trunk/classes/TpResourceMetadata.php 2009-03-21 20:26:36 UTC (rev 1985)
+++ tapirlink/trunk/classes/TpResourceMetadata.php 2009-03-21 20:27:22 UTC (rev 1986)
@@ -275,7 +275,15 @@
else if ( strcasecmp( $name, 'entity' ) == 0 )
{
$r_related_entity =& $this->GetLastRelatedEntity();
- $r_related_entity->SetEntity( new TpEntity() );
+
+ $entity = new TpEntity();
+
+ if ( isset( $attrs['type'] ) )
+ {
+ $entity->SetType( $attrs['type'] );
+ }
+
+ $r_related_entity->SetEntity( $entity );
}
else if ( strcasecmp( $name, 'hasContact' ) == 0 )
{
Modified: tapirlink/trunk/templates/TpMetadataForm.tmpl.php
===================================================================
--- tapirlink/trunk/templates/TpMetadataForm.tmpl.php 2009-03-21 20:26:36 UTC (rev 1985)
+++ tapirlink/trunk/templates/TpMetadataForm.tmpl.php 2009-03-21 20:27:22 UTC (rev 1986)
@@ -119,6 +119,10 @@
<?php print($this->GetHtmlLabel('entityId',true)); ?>
<input type="text" name="<?php print($entity_prefix); ?>_id" value="<?php print($entity->GetIdentifier()); ?>" size="60"/>
<br/><br/>
+<!-- entity type -->
+<?php print($this->GetHtmlLabel('entityType',true)); ?>
+<?php print(TpHtmlUtils::GetCombo($entity_prefix.'_type',$entity->GetType(),$this->GetOptions('entityType'))); ?>
+<br/><br/>
<!-- entity names -->
<div class="box2" align="left">
<?php print($this->GetHtmlLabel('entityName',true)); ?><br/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rd...@us...> - 2009-09-07 22:45:20
|
Revision: 1997
http://digir.svn.sourceforge.net/digir/?rev=1997&view=rev
Author: rdg
Date: 2009-09-07 22:45:02 +0000 (Mon, 07 Sep 2009)
Log Message:
-----------
Resources can now be configured to reject custom output models.
Modified Paths:
--------------
tapirlink/trunk/ChangeLog.txt
tapirlink/trunk/classes/TpHtmlUtils.php
tapirlink/trunk/classes/TpSearchParameters.php
tapirlink/trunk/classes/TpSettings.php
tapirlink/trunk/classes/TpSettingsForm.php
tapirlink/trunk/templates/TpSettingsForm.tmpl.php
tapirlink/trunk/templates/capabilities.tmpl.php
tapirlink/trunk/www/tapir.php
Modified: tapirlink/trunk/ChangeLog.txt
===================================================================
--- tapirlink/trunk/ChangeLog.txt 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/ChangeLog.txt 2009-09-07 22:45:02 UTC (rev 1997)
@@ -1,3 +1,9 @@
+Release 0.7.1 ()
+--------------------------
+(revision )
+
+ * Resources can now be configured to reject custom output models.
+
Release 0.7.0 (2009-03-21)
--------------------------
(revision 1988)
Modified: tapirlink/trunk/classes/TpHtmlUtils.php
===================================================================
--- tapirlink/trunk/classes/TpHtmlUtils.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/classes/TpHtmlUtils.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -70,5 +70,20 @@
} // end of member function GetCheckboxes
+ function GetRadio( $name, $value, $options )
+ {
+ $html = '';
+
+ foreach ( $options as $option_id => $option_value )
+ {
+ $selected = ($value == $option_id) ? ' checked' : '';
+
+ $html .= sprintf( ' <input type="radio" class="checkbox" name="%s" value="%s"%s> <span class="label">%s</span>', $name, $option_id, $selected, $option_value );
+ }
+
+ return $html;
+
+ } // end of member function GetRadio
+
} // end of TpHtmlUtils
?>
\ No newline at end of file
Modified: tapirlink/trunk/classes/TpSearchParameters.php
===================================================================
--- tapirlink/trunk/classes/TpSearchParameters.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/classes/TpSearchParameters.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -244,28 +244,66 @@
$g_dlog->debug( '[Output model]' );
+ // Load resource configuration
+ $r_resources =& TpResources::GetInstance();
+
+ $resource_code = $r_resources->GetCurrentResourceCode();
+
+ $r_resource =& $r_resources->GetResource( $resource_code );
+
+ if ( is_null( $r_resource ) )
+ {
+ // Error is already thrown in GetResource
+ return false;
+ }
+
+ $r_resource->LoadConfig();
+
+ $r_settings =& $r_resource->GetSettings();
+
+ // Check if resource was configured to support output models
+ if ( ! $r_settings->SupportOutputModels() )
+ {
+ $error = 'Provider does not support output models. Check capabilities.';
+ TpDiagnostics::Append( DC_INVALID_REQUEST, $error, DIAG_FATAL );
+
+ return false;
+ }
+
// Here output models must be specified as URLs
// (it's important to check this also for security reasons since
// "fopen" is used to read templates!)
- if ( ! TpUtils::IsUrl( $location ) )
+
+ $output_models = $r_settings->GetOutputModels();
+
+ if ( TpUtils::IsUrl( $location ) )
{
- $r_resources =& TpResources::GetInstance();
+ if ( ! $r_settings->GetCustomOutputModelsAcceptance() )
+ {
+ // Check if resource knows the specified output model
+ $unknown = true;
- $resource_code = $r_resources->GetCurrentResourceCode();
+ foreach ( $output_models as $known_alias => $known_location )
+ {
+ if ( $location == $known_location )
+ {
+ $unknown = false;
+ break;
+ }
+ }
- $r_resource =& $r_resources->GetResource( $resource_code );
+ if ( $unknown )
+ {
+ $error = 'Unknown output model. Check capabilities.';
+ TpDiagnostics::Append( DC_INVALID_REQUEST, $error, DIAG_FATAL );
- if ( is_null( $r_resource ) )
- {
- // Error is already thrown in GetResource
- return false;
+ return false;
+ }
}
-
+ }
+ else
+ {
// Check if output model is a known alias
- $r_resource->LoadConfig();
-
- $r_settings =& $r_resource->GetSettings();
-
$real_location = $r_settings->GetOutputModel( $location );
if ( $real_location )
@@ -275,7 +313,7 @@
}
else
{
- $error = 'Output model is neither a URL nor a known alias.';
+ $error = 'Unknown output model alias. Check capabilities.';
TpDiagnostics::Append( DC_INVALID_REQUEST, $error, DIAG_FATAL );
return false;
@@ -289,8 +327,6 @@
// If cache is enabled
if ( TP_USE_CACHE and TP_OUTPUT_MODEL_CACHE_LIFE_SECS )
{
- $r_resources =& TpResources::GetInstance();
-
$cache_dir = TP_CACHE_DIR . '/' . $r_resources->GetCurrentResourceCode();
$cache_options = array( 'cache_dir' => $cache_dir );
Modified: tapirlink/trunk/classes/TpSettings.php
===================================================================
--- tapirlink/trunk/classes/TpSettings.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/classes/TpSettings.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -40,6 +40,7 @@
var $mInventoryTemplates = array(); // alias => location
var $mSearchTemplates = array(); // alias => location
var $mOutputModels = array(); // alias => location
+ var $mCustomOutputModels = true;
var $mInTags = array();
var $mIsLoaded = false;
@@ -67,6 +68,7 @@
$this->mCaseSensitiveInEquals = false;
$this->mCaseSensitiveInLike = false;
$this->mModifier = '';
+ $this->mCustomOutputModels = true;
$this->mIsLoaded = true;
@@ -86,6 +88,10 @@
$this->mCaseSensitiveInLike = ($caseSensitiveInLike == 'true') ? true : false;
+ $customOutputModels = TpUtils::GetVar( 'custom_output_models', 'true' );
+
+ $this->mCustomOutputModels = ($customOutputModels == 'true') ? true : false;
+
$this->mModifier = TpUtils::GetVar( 'modifier', '' );
// Update datatype, initializing it with NULL
@@ -262,6 +268,8 @@
return false;
}
+ $this->mCustomOutputModels = false;
+
while ( $data = fread( $fp, 4096 ) )
{
if ( !xml_parse( $parser, $data, feof($fp) ) )
@@ -358,6 +366,10 @@
}
}
}
+ else if ( strcasecmp( $name, 'anyOutputModels' ) == 0 )
+ {
+ $this->mCustomOutputModels = true;
+ }
else if ( strcasecmp( $name, 'outputModel' ) == 0 )
{
$num_elements = count( $this->mInTags );
@@ -499,7 +511,7 @@
{
$error = 'Unsupported datatype for date last modified field ('.
$this->mModifierDatatype .'). It must be either '.TYPE_DATETIME.
- ' or '.TYPE_TEXT;
+ ' or '.TYPE_TEXT.'.';
TpDiagnostics::Append( CFG_DATA_VALIDATION_ERROR, $error, DIAG_ERROR );
}
$ret_val = false;
@@ -514,12 +526,27 @@
if ( $raiseErrors )
{
$error = 'Fixed value for "Date last modified" does not match the '.
- 'xsd:dateTime format: [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]';
+ 'xsd:dateTime format: [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm].';
TpDiagnostics::Append( CFG_DATA_VALIDATION_ERROR, $error, DIAG_ERROR );
}
$ret_val = false;
}
+ // Minimum requirements for the search operation
+ if ( empty( $this->mSearchTemplates ) and
+ empty( $this->mOutputModels ) and
+ ! $this->mCustomOutputModels )
+ {
+ if ( $raiseErrors )
+ {
+ $error = 'In order to support search operations, you must declare at '.
+ 'least one search template or one output model or accept '.
+ 'custom output models.';
+ TpDiagnostics::Append( CFG_DATA_VALIDATION_ERROR, $error, DIAG_ERROR );
+ }
+ $ret_val = false;
+ }
+
return $ret_val;
} // end of member function Validate
@@ -612,6 +639,18 @@
} // end of member function SetModified
+ function GetCustomOutputModelsAcceptance( )
+ {
+ return $this->mCustomOutputModels;
+
+ } // end of member function GetCustomOutputModelsAcceptance
+
+ function SetCustomOutputModelsAcceptance( $accept )
+ {
+ $this->mCustomOutputModels = $accept;
+
+ } // end of member function SetCustomOutputModelsAcceptance
+
function AddInventoryTemplate( $alias, $location )
{
if ( strlen( $alias ) == 0 or strlen( $location ) == 0 )
@@ -726,6 +765,12 @@
} // end of member function GetOutputModels
+ function SupportOutputModels( )
+ {
+ return $this->mCustomOutputModels or ! empty( $this->mOutputModels );
+
+ } // end of member function SupportOutputModels
+
function GetInventoryTemplatesXml( )
{
$xml = ( count( $this->mInventoryTemplates ) ) ? "<templates>\n" : "\n";
@@ -753,10 +798,10 @@
$alias = TpUtils::EscapeXmlSpecialChars( $alias );
$location = TpUtils::EscapeXmlSpecialChars( $location );
- $xml .= "\t\t\t\t\t".'<template location="'.$location.'" alias="'.$alias.'"/>'."\n";
+ $xml .= "\t\t\t\t".'<template location="'.$location.'" alias="'.$alias.'"/>'."\n";
}
- $xml .= ( count( $this->mSearchTemplates ) ) ? "\t\t\t\t</templates>\n" : '';
+ $xml .= ( count( $this->mSearchTemplates ) ) ? "\t\t\t</templates>\n" : '';
return $xml;
@@ -764,18 +809,45 @@
function GetOutputModelsXml( )
{
- $xml = ( count( $this->mOutputModels ) ) ? "<knownOutputModels>\n" : "\n";
+ if ( empty( $this->mOutputModels ) and ! $this->mCustomOutputModels )
+ {
+ return "\n";
+ }
- foreach ( $this->mOutputModels as $alias => $location )
+ $xml = '<outputModels>'."\n";
+
+ // Declared output models
+ if ( count( $this->mOutputModels ) )
{
- $alias = TpUtils::EscapeXmlSpecialChars( $alias );
- $location = TpUtils::EscapeXmlSpecialChars( $location );
+ $xml .= "\t\t\t\t<knownOutputModels>\n";
- $xml .= "\t\t\t\t\t".'<outputModel location="'.$location.'" alias="'.$alias.'"/>'."\n";
+ foreach ( $this->mOutputModels as $alias => $location )
+ {
+ $alias = TpUtils::EscapeXmlSpecialChars( $alias );
+ $location = TpUtils::EscapeXmlSpecialChars( $location );
+
+ $xml .= "\t\t\t\t\t".'<outputModel location="'.$location.'" alias="'.$alias.'"/>'."\n";
+ }
+
+ $xml .= "\t\t\t\t</knownOutputModels>\n";
}
+ else
+ {
+ $xml .= "\n";
+ }
- $xml .= ( count( $this->mOutputModels ) ) ? "\t\t\t\t</knownOutputModels>\n" : '';
+ // Custom output models
+ if ( $this->mCustomOutputModels )
+ {
+ $xml .= "\t\t\t\t".'<anyOutputModels>'."\n";
+ $xml .= "\t\t\t\t\t".'<responseStructure>'."\n";
+ $xml .= "\t\t\t\t\t\t".'<basicSchemaLanguage/>'."\n";
+ $xml .= "\t\t\t\t\t".'</responseStructure>'."\n";
+ $xml .= "\t\t\t\t".'</anyOutputModels>'."\n";
+ }
+ $xml .= "\t\t\t".'</outputModels>'."\n";
+
return $xml;
} // end of member function GetOutputModelsXml
@@ -792,7 +864,7 @@
return array( 'mMaxElementRepetitions', 'mMaxElementLevels', 'mLogOnly',
'mCaseSensitiveInEquals', 'mCaseSensitiveInLike', 'mModifier',
'mModified', 'mIsLoaded', 'mInventoryTemplates', 'mSearchTemplates',
- 'mOutputModels' );
+ 'mOutputModels', 'mCustomOutputModels' );
} // end of member function __sleep
Modified: tapirlink/trunk/classes/TpSettingsForm.php
===================================================================
--- tapirlink/trunk/classes/TpSettingsForm.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/classes/TpSettingsForm.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -283,6 +283,11 @@
asort( $options );
array_unshift( $options, '-- columns --' );
}
+ else if ( $id == 'custom_output_models')
+ {
+ $options = array( 'true' => 'accepted',
+ 'false' => 'rejected' );
+ }
return $options;
@@ -362,13 +367,19 @@
'specific search templates, indicate here alias and location '.
'for each one.';
}
- else if ( $labelId == 'output_models')
+ else if ( $labelId == 'pre_output_models')
{
- $label = 'Output models';
+ $label = 'Pre-defined output models';
$doc = 'If you wish to explicitly declare that you support one or more '.
'specific output models, indicate here alias and location '.
'for each one.';
}
+ else if ( $labelId == 'custom_output_models')
+ {
+ $label = 'Custom output models';
+ $doc = 'Indicates whether custom (on-the-fly) output models '.
+ 'based on the mapped concepts are accepted or not.';
+ }
$js = sprintf("onClick=\"javascript:window.open('help.php?name=%s&doc=%s','help','width=400,height=250,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,personalbar=no,locationbar=no,statusbar=no').focus(); return false;\" onMouseOver=\"javascript:window.status='%s'; return true;\" onMouseOut=\"window.status=''; return true;\"", $label, urlencode($doc), $doc);
Modified: tapirlink/trunk/templates/TpSettingsForm.tmpl.php
===================================================================
--- tapirlink/trunk/templates/TpSettingsForm.tmpl.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/templates/TpSettingsForm.tmpl.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -48,7 +48,7 @@
</table>
</td>
</tr>
- <tr bgcolor="#ffffee"><td align="left" valign="middle" width="40%" class="label"><?php print($this->GetHtmlLabel('output_models',false)); ?></td>
+ <tr bgcolor="#ffffee"><td align="left" valign="middle" width="40%" class="label"><?php print($this->GetHtmlLabel('pre_output_models',false)); ?></td>
<td align="left" valign="middle" width="60%">
<table border="0" align="center" width="100%">
<tr>
@@ -68,6 +68,9 @@
</table>
</td>
</tr>
+ <tr bgcolor="#ffffee"><td align="left" valign="middle" width="40%" class="label_required"><?php print($this->GetHtmlLabel('custom_output_models',true)); ?></td>
+ <td align="left" valign="middle" width="60%"><?php print(TpHtmlUtils::GetRadio('custom_output_models',($r_settings->GetCustomOutputModelsAcceptance())?'true':'false',$this->GetOptions('custom_output_models'))); ?><br/></td>
+ </tr>
</table>
<p class="tip"><?php print(TP_MANDATORY_FIELD_FLAG); ?>Indicates mandatory fields</p>
<br/>
Modified: tapirlink/trunk/templates/capabilities.tmpl.php
===================================================================
--- tapirlink/trunk/templates/capabilities.tmpl.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/templates/capabilities.tmpl.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -9,14 +9,7 @@
</inventory>
<search>
<?php print( $r_settings->GetSearchTemplatesXml() ); ?>
- <outputModels>
- <?php print( $r_settings->GetOutputModelsXml() ); ?>
- <anyOutputModels>
- <responseStructure>
- <basicSchemaLanguage/>
- </responseStructure>
- </anyOutputModels>
- </outputModels>
+ <?php print( $r_settings->GetOutputModelsXml() ); ?>
</search>
</operations>
<requests>
Modified: tapirlink/trunk/www/tapir.php
===================================================================
--- tapirlink/trunk/www/tapir.php 2009-08-26 21:51:14 UTC (rev 1996)
+++ tapirlink/trunk/www/tapir.php 2009-09-07 22:45:02 UTC (rev 1997)
@@ -197,7 +197,7 @@
TpDiagnostics::Count( array( DIAG_ERROR, DIAG_FATAL ) ) )
{
$response = new TpResponse( $request );
- $response->ReturnError( 'Failed to parse request' );
+ $response->ReturnError( 'Failed to process request' );
die();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rd...@us...> - 2010-06-11 23:00:53
|
Revision: 2005
http://digir.svn.sourceforge.net/digir/?rev=2005&view=rev
Author: rdg
Date: 2010-06-11 23:00:46 +0000 (Fri, 11 Jun 2010)
Log Message:
-----------
New configuration to specify accepted domains for remote file retrieval.
Modified Paths:
--------------
tapirlink/trunk/ChangeLog.txt
tapirlink/trunk/classes/TpUtils.php
tapirlink/trunk/www/localconfig_dist.php
tapirlink/trunk/www/tapir_globals.php
Modified: tapirlink/trunk/ChangeLog.txt
===================================================================
--- tapirlink/trunk/ChangeLog.txt 2010-06-11 21:49:38 UTC (rev 2004)
+++ tapirlink/trunk/ChangeLog.txt 2010-06-11 23:00:46 UTC (rev 2005)
@@ -4,6 +4,7 @@
* Resources can now be configured to reject custom output models.
* Concepts are now automatically mapped by default.
+ * New configuration to specify accepted domains for remote file retrieval.
Release 0.7.0 (2009-03-21)
--------------------------
Modified: tapirlink/trunk/classes/TpUtils.php
===================================================================
--- tapirlink/trunk/classes/TpUtils.php 2010-06-11 21:49:38 UTC (rev 2004)
+++ tapirlink/trunk/classes/TpUtils.php 2010-06-11 23:00:46 UTC (rev 2005)
@@ -742,11 +742,6 @@
{
return $fp;
}
- else
- {
- // Remove PHP warning
- TpDiagnostics::PopDiagnostic();
- }
}
return null;
@@ -763,19 +758,55 @@
{
global $g_dlog;
- if ( ini_get( 'allow_url_fopen' ) || ! TpUtils::IsUrl( $location ) )
+ if ( ! TpUtils::IsUrl( $location ) )
{
if ( !( $fp = fopen( $location, 'r' ) ) )
{
$g_dlog->debug( 'fopen error' );
+
+ // Remove PHP warning
+ TpDiagnostics::PopDiagnostic();
+
return null;
}
}
+ else if ( ini_get( 'allow_url_fopen' ) )
+ {
+ // This is a URL and we are permitted to fopen urls.
+
+ if ( ! TpUtils::CheckUrl( $location ) )
+ {
+ $error = 'Unauthorized URL domain for: '.$location;
+ TpDiagnostics::Append( DC_IO_ERROR, $error, DIAG_ERROR );
+
+ $g_dlog->debug( 'forbidden resource domain' );
+ return null;
+ }
+
+ if ( !( $fp = fopen( $location, 'r' ) ) )
+ {
+ $g_dlog->debug( 'fopen error' );
+
+ // Remove PHP warning
+ TpDiagnostics::PopDiagnostic();
+
+ return null;
+ }
+ }
else
{
// This is a URL and we are not permitted to fopen urls, so use cURL.
// Open a temporary file to write curl session results to.
+ if ( ! TpUtils::CheckUrl( $location ) )
+ {
+ $error = 'Unauthorized URL domain for: '.$location;
+ TpDiagnostics::Append( DC_IO_ERROR, $error, DIAG_ERROR );
+
+ $g_dlog->debug( 'forbidden resource domain' );
+ return null;
+ }
+
$g_dlog->debug( 'Using curl to retrieve file' );
$fp = tmpfile();
@@ -788,6 +819,10 @@
if ( ! empty( $error ) )
{
$g_dlog->debug( 'curl error: '.$error );
+
+ // Remove PHP warning
+ TpDiagnostics::PopDiagnostic();
+
return null;
}
@@ -799,6 +834,43 @@
} // end of member function OpenFile
+ /**
+ * Check if a URL can be opened.
+ * @param $location string URL
+ * @return boolean
+ */
+ function CheckUrl( $location )
+ {
+ if ( ! defined( 'TP_ACCEPTED_DOMAINS' ) )
+ {
+ return true;
+ }
+
+ $accepted_domains = unserialize( TP_ACCEPTED_DOMAINS );
+
+ if ( ( ! is_array( $accepted_domains ) ) || empty( $accepted_domains ) )
+ {
+ return true;
+ }
+
+ // get host name from URL
+ preg_match( '@^(?:http://)?([^/:]+)@i', $location, $matches );
+ $host = $matches[1];
+
+ foreach( $accepted_domains as $accepted_domain )
+ {
+ $len1 = strlen( $host );
+ $len2 = strlen( $accepted_domain );
+
+ if ( strpos( $host, $accepted_domain ) == $len1-$len2 )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/** Simple function that receives an ADODB meta columns array that
* frequently contains column names in upper case as keys. This method
* returns the same array but using the original column names as keys.
Modified: tapirlink/trunk/www/localconfig_dist.php
===================================================================
--- tapirlink/trunk/www/localconfig_dist.php 2010-06-11 21:49:38 UTC (rev 2004)
+++ tapirlink/trunk/www/localconfig_dist.php 2010-06-11 23:00:46 UTC (rev 2005)
@@ -249,6 +249,17 @@
//define('TP_FILE_RETRIEVAL_BEHAVIOUR', 'prefer_original' or 'prefer_local' or 'only_local');
/**
+* List of accepted domains for remote resource retrieval. Use an empty array for no
+* restrictions, but beware that this is not recommended in production environments
+* for security reasons! If you don't define this setting, there's an internal
+* default value which restricts domains to 127.0.0.1, localhost, tdwg.org,
+* gbif.org and cria.org.br
+*/
+//$domains = array( '127.0.0.1', 'localhost', 'tdwg.org', 'gbif.org', 'cria.org.br' );
+//
+//define( 'TP_ACCEPTED_DOMAINS', serialize( $domains ) );
+
+/**
* When using automatic updates, you can specify an alternative link to
* indicate the latest stable revision number instead of the default link
* below. Note: changing this setting is only recommended for those who are
Modified: tapirlink/trunk/www/tapir_globals.php
===================================================================
--- tapirlink/trunk/www/tapir_globals.php 2010-06-11 21:49:38 UTC (rev 2004)
+++ tapirlink/trunk/www/tapir_globals.php 2010-06-11 23:00:46 UTC (rev 2005)
@@ -353,6 +353,16 @@
define( 'TP_FILE_RETRIEVAL_BEHAVIOUR', 'prefer_original' );
}
+/*
+* Accepted domains for external resource retrieval
+*/
+if ( ! defined( 'TP_ACCEPTED_DOMAINS' ) )
+{
+ $domains = array( '127.0.0.1', 'localhost', 'tdwg.org', 'gbif.org', 'cria.org.br' );
+
+ define( 'TP_ACCEPTED_DOMAINS', serialize( $domains ) );
+}
+
/**
* This is the relative or absolute path to the xpath library
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rd...@us...> - 2010-09-15 00:47:11
|
Revision: 2026
http://digir.svn.sourceforge.net/digir/?rev=2026&view=rev
Author: rdg
Date: 2010-09-15 00:47:04 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Minor updates in the readme file.
Modified Paths:
--------------
tapirlink/trunk/ChangeLog.txt
tapirlink/trunk/README.txt
Modified: tapirlink/trunk/ChangeLog.txt
===================================================================
--- tapirlink/trunk/ChangeLog.txt 2010-09-12 20:02:03 UTC (rev 2025)
+++ tapirlink/trunk/ChangeLog.txt 2010-09-15 00:47:04 UTC (rev 2026)
@@ -1,6 +1,6 @@
-Release 0.7.1 ()
+Release 0.7.1 (2010-09-14)
--------------------------
-(revision )
+(revision 2026)
* Resources can now be configured to reject custom output models.
* Concepts are now automatically mapped by default.
Modified: tapirlink/trunk/README.txt
===================================================================
--- tapirlink/trunk/README.txt 2010-09-12 20:02:03 UTC (rev 2025)
+++ tapirlink/trunk/README.txt 2010-09-15 00:47:04 UTC (rev 2026)
@@ -57,24 +57,31 @@
http://example.net/tapirlink/tapir.php
However, this will only give you generic documentation about
-the service. Real interaction with the service can only be
-done through one of the resources' access points. After
-configuring TapirLink, you will notice that each resource has
-a local id (or code). The local id must be appended to the
-previous URI to give you the corresponding address of the
-service, like:
+the service. Real interaction with the service can only happen
+through one of the end points. After configuring TapirLink, you
+will notice that each resource has a local id (or code). The
+local id must be appended to the previous URI to give you the
+corresponding address of the service, like:
http://example.net/tapirlink/tapir.php/myres/
TapirLink can map conceptual schemas that either follow the
-DarwinCore pattern or the CNS configuration file pattern. In the
-DarwinCore pattern, concepts are defined as global elements
-of an XML Schema document having a "substitutionGroup" attribute
-referencing dwe:dwElement (where "dwe" is a prefix for the
-namespace "http://rs.tdwg.org/dwc/dwelement"). Please note that
-this is NOT the original format of DarwinCore. It comes from
-a more recent version of the schema.
+DarwinCore patterns or the CNS configuration file patterns.
+For specimen/observation data providers, TapirLink has been
+tested with:
+
+* The original version of DarwinCore;
+* The second generation of DarwinCore (with the curatorial and
+geospatial extensions);
+* The official version of DarwinCore approved by TDWG
+(DarwinCore terms);
+* ABCD 2.06
+
+For taxonomic data providers TapirLink has been tested with:
+
+* TCS 1.01
+
TapirLink allows each resource to map one or more conceptual
schemas, but it will only be able to serve instances of a single
"class" or "entity". In other words, when mapping multiple
@@ -144,12 +151,12 @@
If you are getting unexpected blank pages in your browser when running
scripts, try increasing the memory limit of your PHP instance. Look
for the option "memory_limit" in your php.ini file. The default value
-is usually 8M. Try setting it to at least 32M. This may be needed if
-your TapirLink instance will be used with big and complicated response
-structures or if you set the maximum number of element repetitions
-to a high value.
+in older PHP versions was 8M. Recent versions come with 128M. I suggest
+at least 32M. TapirLink consumes more memory if you use it with big and
+complicated response structures or if you set the maximum number of
+element repetitions to a high value.
-When you are having problems, it is also be a good idea to activate
+When you are having problems, it is also a good idea to activate
debugging. To do this, copy www/localconfig_dist.php to
www/localconfig.php and enable the line where _DEBUG is set to true.
Remember to rollback this change when you are in a production environment.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rd...@us...> - 2010-09-15 00:51:21
|
Revision: 2027
http://digir.svn.sourceforge.net/digir/?rev=2027&view=rev
Author: rdg
Date: 2010-09-15 00:51:15 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Updated version number.
Modified Paths:
--------------
tapirlink/trunk/ChangeLog.txt
tapirlink/trunk/make_release.sh
tapirlink/trunk/www/tapir_globals.php
Modified: tapirlink/trunk/ChangeLog.txt
===================================================================
--- tapirlink/trunk/ChangeLog.txt 2010-09-15 00:47:04 UTC (rev 2026)
+++ tapirlink/trunk/ChangeLog.txt 2010-09-15 00:51:15 UTC (rev 2027)
@@ -1,6 +1,6 @@
Release 0.7.1 (2010-09-14)
--------------------------
-(revision 2026)
+(revision 2027)
* Resources can now be configured to reject custom output models.
* Concepts are now automatically mapped by default.
Modified: tapirlink/trunk/make_release.sh
===================================================================
--- tapirlink/trunk/make_release.sh 2010-09-15 00:47:04 UTC (rev 2026)
+++ tapirlink/trunk/make_release.sh 2010-09-15 00:51:15 UTC (rev 2027)
@@ -34,7 +34,7 @@
TARNAME=TapirLink-$TP_VERSION.tar.gz
-tar --create --file $TARNAME --verbose --gzip --exclude=localconfig.php --exclude=.svn --exclude=darwin.xsl --exclude=darwin.xsd --exclude=darwin.xml --exclude=darwin.xml.bak --exclude=darwin.php --exclude=resources.tbl.lock --exclude=schema.tbl.lock --exclude=test_filter.php README.txt AUTHORS.txt INSTALL.txt COPYING.txt ChangeLog.txt www/ lib/ classes/ templates/ admin/ config/schemas.xml config/lsid_settings.xml.tmpl log/ cache/ stats/ statistics/
+tar --create --file $TARNAME --verbose --gzip --exclude=localconfig.php --exclude=.svn --exclude=darwin.xsl --exclude=darwin.xsd --exclude=darwin.xml --exclude=darwin.xml.bak --exclude=darwin.php --exclude=resources.tbl.lock --exclude=schema.tbl.lock --exclude=test_filter.php --exclude=TODO.txt --exclude=CLONE.txt README.txt AUTHORS.txt INSTALL.txt COPYING.txt ChangeLog.txt www/ lib/ classes/ templates/ admin/ config/schemas.xml config/lsid_settings.xml.tmpl log/ cache/ stats/ statistics/
# Untar in a temporary directory
DIRNAME=tapirlink-$TP_VERSION
Modified: tapirlink/trunk/www/tapir_globals.php
===================================================================
--- tapirlink/trunk/www/tapir_globals.php 2010-09-15 00:47:04 UTC (rev 2026)
+++ tapirlink/trunk/www/tapir_globals.php 2010-09-15 00:51:15 UTC (rev 2027)
@@ -586,7 +586,7 @@
define( 'TP_MIN_PHP_VERSION', '4.2.3' );
-define( 'TP_VERSION', '0.7.0' );
+define( 'TP_VERSION', '0.7.1' );
$revision = '$Revision$.';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rd...@us...> - 2014-02-05 13:01:30
|
Revision: 2040
http://sourceforge.net/p/digir/svn/2040
Author: rdg
Date: 2014-02-05 13:01:27 +0000 (Wed, 05 Feb 2014)
Log Message:
-----------
New code for time profiling on search operations
Modified Paths:
--------------
tapirlink/trunk/classes/TpDiagnostics.php
tapirlink/trunk/classes/TpResponse.php
tapirlink/trunk/classes/TpSearchResponse.php
tapirlink/trunk/www/localconfig_dist.php
tapirlink/trunk/www/tapir.php
tapirlink/trunk/www/tapir_globals.php
Modified: tapirlink/trunk/classes/TpDiagnostics.php
===================================================================
--- tapirlink/trunk/classes/TpDiagnostics.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/classes/TpDiagnostics.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -143,7 +143,7 @@
if ( _DEBUG )
{
- $duration = sprintf( '%0.4f', TpUtils::MicrotimeFloat()-INITIAL_TIMESTAMP );
+ $duration = sprintf( 'Total elapsed time: %0.4f', TpUtils::MicrotimeFloat()-INITIAL_TIMESTAMP );
TpDiagnostics::Append( DC_DURATION, $duration, DIAG_INFO );
if ( function_exists( 'memory_get_peak_usage' ) )
Modified: tapirlink/trunk/classes/TpResponse.php
===================================================================
--- tapirlink/trunk/classes/TpResponse.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/classes/TpResponse.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -67,6 +67,8 @@
function Process()
{
+ $start_time = ( TP_ENABLE_PROFILING ) ? TpUtils::MicrotimeFloat() : 0;
+
// In some cases it is necessary to replace headers (see "header" call
// inside TpXmlGenerator), so avoid echoing content straight away.
ob_start();
@@ -106,6 +108,8 @@
// Header should be always dynamic, leave it out from cache
$this->Header();
+ $start_time = $this->_AddDuration( $start_time, 'Header' );
+
if ( $this->mCacheable and TP_USE_CACHE and $this->mCacheLife )
{
$g_dlog->debug( 'Response cache is activated' );
@@ -131,11 +135,15 @@
$log_data = $this->_GetLogData();
$this->Log( $log_data );
+
+ $start_time = $this->_AddDuration( $start_time, 'Cached response' );
}
else
{
$this->Body();
+ $start_time = ( TP_ENABLE_PROFILING ) ? TpUtils::MicrotimeFloat() : 0;
+
// Note: better to place logging after Body() so that the SQL can
// also be logged.
$log_data = $this->_GetLogData();
@@ -143,6 +151,8 @@
$this->Log( $log_data );
$this->Footer();
+
+ $start_time = $this->_AddDuration( $start_time, 'Log and footer' );
}
}
@@ -181,6 +191,8 @@
$LogStruct->Initialize( $log_data );
$LogStruct->WriteRequestResult( $stats_log );
+
+ $start_time = $this->_AddDuration( $start_time, 'Statistics' );
}
ob_end_flush();
@@ -429,5 +441,19 @@
} // end of member function _GetLogData
+ function _AddDuration( $start, $msg )
+ {
+ if ( TP_ENABLE_PROFILING )
+ {
+ $end = TpUtils::MicrotimeFloat();
+ $duration = sprintf( '%s: %0.4f', $msg, $end-$start );
+ TpDiagnostics::Append( DC_DURATION, $duration, DIAG_INFO );
+ return $end;
+ }
+
+ return 0;
+
+ } // end of member function _AddDuration
+
} // end of TpResponse
?>
\ No newline at end of file
Modified: tapirlink/trunk/classes/TpSearchResponse.php
===================================================================
--- tapirlink/trunk/classes/TpSearchResponse.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/classes/TpSearchResponse.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -67,6 +67,8 @@
function Body()
{
+ $start_time = ( TP_ENABLE_PROFILING ) ? TpUtils::MicrotimeFloat() : 0;
+
global $g_dlog;
$g_dlog->debug( '[Search Body]' );
@@ -101,6 +103,8 @@
$max_levels = $r_settings->GetMaxElementLevels();
+ $start_time = $this->_AddDuration( $start_time, 'Search config' );
+
// Output model
$r_output_model =& $parameters->GetOutputModel();
@@ -208,6 +212,8 @@
return;
}
+ $start_time = $this->_AddDuration( $start_time, 'Output model setup' );
+
// Prepare SQL builder
$g_dlog->debug( '--------------' );
@@ -322,6 +328,8 @@
$sql_builder->AddRecordSource( $r_tables->GetStructure() );
+ $start_time = $this->_AddDuration( $start_time, 'SQL builder' );
+
// DB connection
if ( ! $r_data_source->Validate() )
@@ -334,6 +342,8 @@
$db_encoding = $r_data_source->GetEncoding();
+ $start_time = $this->_AddDuration( $start_time, 'DB connection' );
+
// Filter
$filter = $parameters->GetFilter();
@@ -417,6 +427,8 @@
$limit = $max_repetitions;
}
+ $start_time = $this->_AddDuration( $start_time, 'Filter' );
+
// Count total matched records, if requested
$matched = 0;
@@ -497,6 +509,8 @@
$g_dlog->debug( 'Caching count SQL: '.$matched );
}
}
+
+ $start_time = $this->_AddDuration( $start_time, 'Record count' );
}
// Retrieve records
@@ -507,8 +521,14 @@
$encoded_sql = TpServiceUtils::EncodeSql( $this->mMainSql, $db_encoding );
+ $this->_AddDuration( $start_time, 'Search query setup' );
+
+ $start_time = ( TP_ENABLE_PROFILING ) ? TpUtils::MicrotimeFloat() : 0;
+
$result_set =& $cn->SelectLimit( $encoded_sql, $limit+1, $start );
+ $start_time = $this->_AddDuration( $start_time, 'Search query' );
+
if ( ! is_object( $result_set ) )
{
$err = $cn->ErrorMsg();
@@ -556,6 +576,8 @@
echo $main_content;
+ $start_time = $this->_AddDuration( $start_time, 'Search XML output' );
+
// Search Summary
if ( $this->mRequest->GetEnvelope() )
@@ -581,6 +603,8 @@
echo ' />';
echo "\n</search>";
+
+ $start_time = $this->_AddDuration( $start_time, 'Search XML summary' );
}
$result_set->Close();
Modified: tapirlink/trunk/www/localconfig_dist.php
===================================================================
--- tapirlink/trunk/www/localconfig_dist.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/www/localconfig_dist.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -83,6 +83,12 @@
//define('_DEBUG', true);
/**
+* Set this true to enable profiling. This will ouput messages about
+* durations of the main tasks (search operations only).
+*/
+//define('TP_ENABLE_PROFILING', true);
+
+/**
* Set to true if you want to store detailed debugging information in a separate file
*/
//define('TP_LOG_DEBUG', true);
Modified: tapirlink/trunk/www/tapir.php
===================================================================
--- tapirlink/trunk/www/tapir.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/www/tapir.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -232,6 +232,12 @@
die();
}
+if ( TP_ENABLE_PROFILING )
+{
+ $duration = sprintf( 'Initial setup: %0.4f', TpUtils::MicrotimeFloat()-INITIAL_TIMESTAMP );
+ TpDiagnostics::Append( DC_DURATION, $duration, DIAG_INFO );
+}
+
$response->Process();
exit();
Modified: tapirlink/trunk/www/tapir_globals.php
===================================================================
--- tapirlink/trunk/www/tapir_globals.php 2013-11-11 16:37:32 UTC (rev 2039)
+++ tapirlink/trunk/www/tapir_globals.php 2014-02-05 13:01:27 UTC (rev 2040)
@@ -79,6 +79,11 @@
define( 'TP_WWW_DIR', $root_dir );
}
+if ( ! defined( 'TP_ENABLE_PROFILING' ) )
+{
+ define( 'TP_ENABLE_PROFILING', false );
+}
+
// The full path to the directory used to contain configuration.
if ( ! defined( 'TP_CONFIG_DIR' ) ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|