Hi Looks like the 'Public' directory got lost from the module download. got it from here: http://www.opencalais.com/files/CalaisMarmoset_08Dec17.zip

after sorting that out,getting error:

warning: Invalid argument supplied for foreach() in /home/public_html/chenoco.com/modules/calais_marmoset/public/calaismf/common.php on line 92.

I found the same trouble reported here: http://www.opencalais.com/node/7506

Regards, Jim

Comments

emackn’s picture

Yes, you will need to download the Marmoset package separately. I added that to the project page. You can also follow the documentation page, http://drupal.org/node/361166, and get it working. :)

jjcheno’s picture

Status: Active » Closed (fixed)
Webster619’s picture

Status: Closed (fixed) » Active

I installed this separately and still received the same error. I followed all of the instructions for page.tpl.php and the edits to the conf and footer files as a part of CM.

Ideas?

socialnicheguru’s picture

Don't forget to add the trailing '/' to the end of Path to Marmoset Library:

sites/all/modules/calais_marmoset/marmoset_package/public/calaismf/

emackn’s picture

Assigned: Unassigned » emackn

Webster619, you still having troubles?

Webster619’s picture

Disabled the modules for now. I'll double check the trailing slash and get back if I have issues. Thanks for the replies.

Webster619’s picture

hmmm. This step confuses me. I am loading everything through filezilla. If I try to add slash after a folder name it won't take it.

Am I missing something here?

Thanks.

Webster619’s picture

I don't know any php, but I noticed that the original files (footer and conf) contain opening and closing php tags that seem to work for the entire file.

The changes place php tags around each chunk of code. Is this right? or do I need to leave out the php tags for each piece of code. Does it matter?

Thanks.

Webster619’s picture

I followed the instructions again and now I get this error: http://drupal.org/node/470924

Fatal error: require_once() [function.require]: Failed opening required 'modules/calais_marmoset/marmoset/public/calaismf/header.php' (include_path='.:') in /home/webtb858/public_html/personaltrainingschools.org/themes/acquia_marina/page.tpl.php on line 6

I'll just paste all my code and maybe this will help.

Here is where all my stuff is:

/modules/calais_marmoset/marmoset_package/public/calaismf

conf file:

<?php
/*
 * Copyright (c) 2008, ClearForest Ltd.
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * 		- 	Redistributions of source code must retain the above 
 * 			copyright notice, this list of conditions and the 
 * 			following disclaimer.
 * 
 * 		- 	Redistributions in binary form must reproduce the above 
 * 			copyright notice, this list of conditions and the 
 * 			following disclaimer in the documentation and/or other 
 * 			materials provided with the distribution. 
 * 
 * 		- 	Neither the name of ClearForest Ltd. nor the names of 
 * 			its contributors may be used to endorse or promote 
 * 			products derived from this software without specific prior 
 * 			written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * OpenCalais Microformats Injector - configuration
 *
 * Change the values in this page to configure the Microformats Injector's
 * behavior.
 * 
 */

/*
 * The Calais API key used in calls to the Web service.
 * 
 * ***NOTE*** You must change this value to a valid key. To obtain an API key
 * see http://www.opencalais.com
 */
<?php
$GLOBALS ['calaismf_APIKey'] = variable_get('calais_marmoset_api_key', '');
global $calaismf_APIKey;
?>

/*
 * Timeout in seconds for the Calais Enlighten call
 * This HTTP POST request is made when the injector identifies the caller
 * as a search robot. If this timeout expires the original page is
 * returned to the robot.
 */
<?php
$GLOBALS['global $calaismf_InvokeEnlightenTimeout'] = 60;
global $calaismf_InvokeEnlightenTimeout;

?>

/*
 * List of substrings to look for in the caller's User-Agent field, in order
 * to determine whether it is a search robot.
 * 
 * Any caller with a User-Agent that includes one of the strings in this 
 * array, will be treated as a search robot, and the injector will place
 * the Microformats in the returned page.
 * 
 * Comparison is case sensitive.
 * 
 * Initially only Slurp (identifies Yahoo's crawler) and Googlebot are included
 */
<?php
$u_agent_string = variable_get('calais_marmoset_UserAgentSubstringList', 'Slurp');
$u_agents = explode("\n", trim($u_agent_string));
$GLOBALS['calaismf_UserAgentSubstringList'] = $u_agents;
global $calaismf_UserAgentSubstringList;

?>

/*
 * Identification of OpenCalais Microformats Injector in log output
 */
<?php
$GLOBALS['calaismf_LogIdentity'] = "CalaisMFInjector";
global $calaismf_LogIdentity;
?>

/*
 * reltagBaseURL is used as the base URL for OpenCalais 
 * generated Rel-Tags microformats. (More information about OpenCalais 
 * microformats support can be found in the OpenCalais API 
 * documentation at http://www.opencalais.com/page/documentation).
 * 
 * Rel-tags generated by Calais will be injected into your page when
 * requested by a search robot (HTML <a> elements). By default the 
 * link's URL (href) will equal '/Tag' where Tag is the identified
 * Calais rel-tag.
 * 
 * If you'd like to attach a prefix to the tag, put it here. If you
 * change this value to "http://www.example.com", the links for Tag
 * will now point to http://www.example.com/Tag
 */
<?php
$site_base_url = variable_get('calais_marmoset_base_url', url('<front>', array('absolute'=> true)));
$GLOBALS['calaismf_ReltagBaseURL'] = $site_base_url;
global $calaismf_ReltagBaseURL;
?>

/*
 * THE VALUES BELOW ARE FOR INTERNAL USE - PLEASE DO NOT CHANGE  
 */
<?php
$GLOBALS['calaismf_OverrideDefaultURL'] = false;
global $calaismf_OverrideDefaultURL;

$GLOBALS['calaismf_CalaisWebServiceURL'] = "";
global $calaismf_CalaisWebServiceURL;

$GLOBALS['calaismf_VerifySSLCertificates'] = true;
global $calaismf_VerifySSLCertificates;
?>
?>

footer file

<?php
/*
 * Copyright (c) 2008, ClearForest Ltd.
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * 		- 	Redistributions of source code must retain the above 
 * 			copyright notice, this list of conditions and the 
 * 			following disclaimer.
 * 
 * 		- 	Redistributions in binary form must reproduce the above 
 * 			copyright notice, this list of conditions and the 
 * 			following disclaimer in the documentation and/or other 
 * 			materials provided with the distribution. 
 * 
 * 		- 	Neither the name of ClearForest Ltd. nor the names of 
 * 			its contributors may be used to endorse or promote 
 * 			products derived from this software without specific prior 
 * 			written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * OpenCalais Microformats Injector - footer include 
 *
 * This file is to be included using require_once in any PHP file
 * on your Web site, for which you want the injector to insert 
 * Microformats data when called by a search robot. It should be
 * included at the end of the file.
 * 
 * In addition you have to include the header file header.php at 
 * the beginning of each file, after defining CALAISMF_INCLUDE_DIR to
 * point to the calaismf directory.
 * 
 * Example:
 * 
 * Given the following PHP file:
 * 
 * <html>
 * <head>
 * <title>Hello World!</title>
 * </head>
 * <body>
 * <?php echo "Hello World!"; ?>
 * </body>
 * </html>
 * 
 * Change to:
 *
 * <?php
 * 		define("CALAISMF_INCLUDE_DIR", "path/to/calaismf/"); 
 * 		require_once (CALAISMF_INCLUDE_DIR . "header.php");
 * ?> 
 * <html>
 * <head>
 * <title>Hello World!</title>
 * </head>
 * <body>
 * <?php echo "Hello World!"; ?>
 * </body>
 * </html>
 * <?php require_once (CALAISMF_INCLUDE_DIR . "footer.php"); ?>
 */

require_once (CALAISMF_INCLUDE_DIR . "conf.php");
require_once (CALAISMF_INCLUDE_DIR . "common.php");
require_once (CALAISMF_INCLUDE_DIR . "calaisif/CalaisPHPIf.php");

<?php
global $calaismf_inject_arr;
$calaismf_inject_arr = array();

global $calaismf_level;
$calaismf_level     = 0;

global $calaismf_l2_tag;
$calaismf_l2_tag    = "";

global $calaismf_l3_tag;
$calaismf_l3_tag    = "";   // for future use

global $calaismf_parse_err;
$calaismf_parse_err   = false;
?>

if (calaismf_is_search_robot())
{
		/*
		 * Set the script's time limit to allow enough time for the
		 * Web service call to take place.
		 * The call here restarts the timer. The extra 5 secs ensure
		 * the CURL timeout will expire first
		 */
        set_time_limit($calaismf_InvokeEnlightenTimeout + 5);

	/*
	 * Retrieve the buffer's content
	 */
	$origpage = ob_get_contents();
	ob_end_clean();
	
	/**
	 * Invoke Calais Enlighten on original content
	 */
	$cif = new CalaisPHPIf($calaismf_APIKey);
	$cif->setContentType("text/html");
	$cif->setOutputFormat("text/microformats");
	$cif->setReltagBaseURL($calaismf_ReltagBaseURL);
	$cif->setTimeout($calaismf_InvokeEnlightenTimeout);
	$cif->setVerifyCert($calaismf_VerifySSLCertificates);
	if ($calaismf_OverrideDefaultURL)
	{
		$cif->setCalaisURL($calaismf_CalaisWebServiceURL);
	}
	
	$mfdata = $cif->callEnlighten($origpage);
	$mfdata = html_entity_decode($mfdata);
	
	if ($cif->isLastErr())
	{
		/*
		 * Error in call - log error and output original page
		 */
		calaismf_log_error($cif->getLastErr());
		echo $origpage;
	}
	else
	{
		/*
		 * Parse the returned data and build the injected string
		 * (returned Microformats are packed within XML)
		 */
  		$xmlp = xml_parser_create();
  		xml_parser_set_option($xmlp, XML_OPTION_CASE_FOLDING, 0);
  		xml_parser_set_option($xmlp, XML_OPTION_SKIP_WHITE, 0);
  		xml_set_element_handler($xmlp, "calaismf_parse_open", "calaismf_parse_close");
  		xml_set_character_data_handler($xmlp, "calaismf_parse_data");
  		
  		if (xml_parse($xmlp, $mfdata, TRUE) == 0)
  		{
  			/*
  			 * Parse error
  			 */
  			calaismf_log_error("Failed to parse Microformats XML - error: ".
  				xml_error_string(xml_get_error_code($xmlp)). " in line ".
  				xml_get_current_line_number($xmlp));
  				
  			echo $origpage;
  		} 
  		else if ($calaismf_parse_err)
  		{
  			/*
  			 * Parse error - detailed error logged within callback functions
  			 */
  			echo $origpage;
  		}
  		else
  		{
  			/*
  			 * Parsed successfully - inject string
  			 */
  			$afterbodyidx = find_after_body_index($origpage);
  			if ($afterbodyidx < 0)
  			{
  				calaismf_log_error("Failed to find body element in original page");
  				echo $origpage;
  			}
  			else
  			{
  				/*
  				 * Success - glue it all together and inject
  				 */
  				$injectstr = implode("", $calaismf_inject_arr);
  				
  				echo substr($origpage, 0, $afterbodyidx).$injectstr.
  					substr($origpage, $afterbodyidx);
  			} 
  		}
  		
  		xml_parser_free($xmlp);
		
	}
	
}

/**
 * Callback function called by xml_parse when opening an XML tag
 */
function calaismf_parse_open($parser, $element_name, $element_atts) {

	global $calaismf_inject_arr;
	global $calaismf_level;
	global $calaismf_l2_tag;
	global $calaismf_l3_tag;
	global $calaismf_parse_err;

	if ($calaismf_parse_err)
	{
		return;
	}
	
	if ($calaismf_level == 0)
	{
		/*
		 * Level 1 - the string tag
		 */
		if ($element_name != "string")
		{
			calaismf_log_error("Failed to parse Microformats - root tag is not string - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}
		
	}
	else if ($calaismf_level == 1)
	{
		/*
		 * Level 1 - the OpenCalaisMicroformats tag
		 */
		if ($element_name != "OpenCalaisMicroformats")
		{
			calaismf_log_error("Failed to parse Microformats - level 1 tag is not OpenCalaisMicroformats - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}
	
	}
	else if ($calaismf_level == 2)
	{
		/*
		 * Level 2 - description or Microformats
		 */
		if ($element_name == "Description" || $element_name == "Microformats")
		{
			$calaismf_l2_tag = $element_name;
		}
		else
		{
			calaismf_log_error("Failed to parse Microformats - element at level 2 is not Description or Microformats - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}	
	}
	else if ($calaismf_level == 3)
	{
		/*
		 * Level 3 - ignore anything under description and process
		 * 			 cards, calendars and rel-tags under Microformats
		 */
		if ($calaismf_l2_tag == "Microformats")
		{
			if ($element_name != "cards" && $element_name != "calendars" &&
				$element_name != "rel-tags")
			{
				calaismf_log_error("Failed to parse Microformats - element below Microformats is not cards/calendars/rel-tags - ".$element_name);
				$calaismf_parse_err = true;
				return;		
			}
			
			$calaismf_l3_tag = $element_name;
		}
	}
	else if ($calaismf_level == 4)
	{
		/*
		 * Level 4 - ignore anything under description and process
		 * 			 any tag under Microformats (this is a no-op, since we
		 * 			 keep outer tag as cards/calendars/rel-tags as they are
		 * 			 all processed the same)
		 */
	}
	else 
	{
		/*
		 * Level 5+ - add opening tag to injection strings array
		 */
		$inject = "<".$element_name;
		foreach ($element_atts as $name => $value)
  		{
    		$inject .= " ".$name."=\"".$value."\"";
  		}
 		$inject .= ">";
		$calaismf_inject_arr[] = $inject;
	}
	
	$calaismf_level++;
}

/**
 * Callback function called by xml_parse when closing an XML tag
 */
function calaismf_parse_close($parser, $element_name) {

	global $calaismf_inject_arr;
	global $calaismf_level;
	global $calaismf_l2_tag;
	global $calaismf_l3_tag;
	global $calaismf_parse_err;

	if ($calaismf_parse_err)
	{
		return;
	}
	
	if ($calaismf_level == 0)
	{
		calaismf_log_error("Failed to parse Microformats - internal error");
		$calaismf_parse_err = true;
		return;		
	}

	if ($calaismf_level == 1)
	{
		/*
		 * Closing Level 0 - the string tag (DONE!)
		 */

		if ($element_name != "string")
		{
			calaismf_log_error("Failed to parse Microformats - closing tag for root is not string - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}
	}	
	if ($calaismf_level == 2)
	{
		/*
		 * Closing Level 1 - the OpenCalaisMicroformats tag 
		 */

		if ($element_name != "OpenCalaisMicroformats")
		{
			calaismf_log_error("Failed to parse Microformats - closing tag for level 1 is not OpenCalaisMicroformats - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}
	}
	else if ($calaismf_level == 3)
	{
		/*
		 * Closing Level 2 - Description or Microformats
		 */
		if ($element_name != "Description" && $element_name != "Microformats")
		{
			calaismf_log_error("Failed to parse Microformats - closing tag of element at level 2 is not Description or Microformats - ".$element_name);
			$calaismf_parse_err = true;
			return;		
		}
		
		$calaismf_l2_tag = "";
	}
	else if ($calaismf_level == 4)
	{
		/*
		 * Closing Level 3 - ignore anything under description and close
		 * 			 		 cards, calendars and rel-tags under Microformats
		 */
		if ($calaismf_l2_tag == "Microformats")
		{
			if ($element_name != "cards" && $element_name != "calendars" &&
				$element_name != "rel-tags")
			{
				calaismf_log_error("Failed to parse Microformats - closing element below Microformats is not cards/calendars/rel-tags - ".$element_name);
				$calaismf_parse_err = true;
				return;		
			}
			
			$calaismf_l3_tag = "";
		}
	}
	else if ($calaismf_level == 5)
	{
		/*
		 * Closing Level 4 - no-op
		 */
	}	
	else if ($calaismf_level > 5)
	{
		/*
		 * Closing Level 5+ - add closing tag to injection strings array
		 */
		$calaismf_inject_arr[] = "</".$element_name.">".
				($calaismf_level == 5 ? "\n" : ""); // aesthetics
	}

	$calaismf_level--;
}

/*
 * Callback function called by xml_parse when processing data
 */
function calaismf_parse_data($parser, $data) {
  
	global $calaismf_inject_arr;
	global $calaismf_level;
	global $calaismf_l2_tag;
	global $calaismf_l3_tag;
	global $calaismf_parse_err;

	if ($calaismf_parse_err)
	{
		return;
	}

	/*
	 * Anything under Microformats in level 4+ gets injected
	 */
	if ($calaismf_l2_tag == "Microformats" && $calaismf_level > 4)
	{
		$calaismf_inject_arr[] = $data;
	}
}

/*
 * Return the index within $htmldata following the first opening tag <body ...>
 * 
 * Returns -1 in case of errors
 * 
 * NOTE This function goes through the HTML manually in order to avoid
 * PHP bug 30257 which causes xml_get_current_byte_index() to behave
 * inconsistently
 * 
 * Although exactly one <body> element should be found (as opposed to 
 * &lt;body of which there can be many), the implementation is lenient
 * so that invalid HTML with multiple bodies gets the Microformats injection
 * as well
 */
function find_after_body_index($htmldata)
{
	/*
	 * Get the first occurrence
	 */
	$startpos = stripos_outside_comments($htmldata, "<body");
	if ($startpos === FALSE)
	{
		// No body elements
		return -1;
	}
	
	$endpos = stripos_outside_comments($htmldata, ">", $startpos + 1);
	if ($endpos === FALSE)
	{
		// body element not closed
		return -1;
	}
	
	if (stripos_outside_comments($htmldata, "/>", $startpos + 1) === ($endpos - 1))
	{
		// empty body element
		return -1;
	}
	
	return $endpos + 1;
}

/**
 * Same as stripos() except that needle must be found outside 
 * XML comments (<!-- -->)
 */
function stripos_outside_comments($haystack, $needle, $offset = 0)
{
	$commentspos = array();
	
	/**
	 * First map the comments in the string by creating an array
	 * of (start,end) pairs
	 */
	$idx = $offset;
	while($idx < strlen($haystack))
	{
		$start = stripos($haystack, "<!--", $idx);
		$end = FALSE;
		if ($start !== FALSE)
		{
			$end = stripos($haystack, "-->", $start + 1);
		}
		
		if ($start !== FALSE && $end !== FALSE)
		{
			$commentspos[] = array($start,$end+2);
			$idx = $end + 3;
		}
		else
		{
			break;
		}
	}

	/**
	 * Now loop until finding an occurrence outside the comments
	 */
	$ret = FALSE;
	$candidate = $offset - 1;
	while ($ret === FALSE && $candidate !== FALSE)
	{
		$candidate = stripos($haystack, $needle, $candidate + 1);
		if ($candidate !== FALSE)
		{
			$incomment = false;
			foreach($commentspos as $pair)
			{
				if ($pair[0] <= $candidate && $pair[1] >= $candidate)
				{
					$incomment = true;
					break;
				}
			}
			
			if (!$incomment)
			{
				$ret = $candidate;
			}
		}
	}

	return $ret;
}
?>
WildBill’s picture

Webster619, your error in #9 is different from the error that originally started this issue ticket. That said, I had similar errors and solved a lot of them by CHMOD'ing _all_ of the subdirectories to 755.

Anonymous’s picture

@ the problem with the invalid arg on line 92 in common.php:
http://drupal.org/node/361166 - If you have that error, you still need to edit conf.php