<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="owlencrypter" active="1">
	<title>Owl Encrypter</title>
	<description>Allows encrypted access between Owl client and vBulletin Forums</description>
	<version>1.0.0</version>
	<url />
	<versioncheckurl />
	<apm_releasedate>0</apm_releasedate>
	<apm_author />
	<apm_relatedurl />
	<apm_extrainfo />
	<apm_extraedit />
	<dependencies>
	</dependencies>
	<codes>
	</codes>
	<templates>
	</templates>
	<plugins>
		<plugin active="1" executionorder="1">
			<title>Owl Encrypter - Payload Process and Functions</title>
			<hookname>init_startup</hookname>
			<phpcode><![CDATA[//This plugin will decrypt the payload if encryption received from owl client

global $vbulletin;
$vbo = &$vbulletin->options; 
 
//Looking for THIS_SCRIPT value should limit this to front-end pages only
if ($vbo['owle_en'] AND defined("THIS_SCRIPT"))
{
  $postdata = file_get_contents("php://input");   
 
  // if the Content-Type is application/x-owl-encrypted
  if (!(strpos($_SERVER["CONTENT_TYPE"], 'application/x-owl-encrypted') === FALSE))
  {
    // decrypt the post data
    $postdata = owl_decryptRJ256($vbo['owle_key'], $vbo['owle_salt'], $postdata);
    define ("OWL_ENCRYPTED", 1); //Set encrypted flag for later plugins

    //parse_str creates array from a query string
    parse_str ($postdata, $_POST); //Should load decoded postdata back into $_POST array
    //Merge new $_POST back into $_REQUEST
    $_REQUEST = array_merge ($_REQUEST, $_POST);
  }

  /******
  if ($vbu['userid'] == 846 AND THIS_SCRIPT == 'index')
  {
    echo "<pre>"; print_r($postdata); echo "</pre>"; 
  }
  ******/
}


//Required functions

if ($vbo['owle_en'])
{
   /**
   * Use Rijndael encryption to encrypt a string
   *
   * @param string $key key used for encryption
   * @param string $iv salt	 
   * @param string $string_to_encrypt plain text string to encrypt	
   * @return string encrypted string 
   */

  function owl_encryptRJ256($key,$iv,$string_to_encrypt)
  {
    $rtn = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_encrypt, MCRYPT_MODE_CBC, $iv);
    $rtn = base64_encode($rtn);
    return($rtn);
  }

   /**
   * Decrypt string using Rijndael encyption
   *
   * @param string $key key used for encryption
   * @param string $iv salt
   * @param string $string_to_decrypt encrypted string to descrypt	
   * @return string plain text string 
   */

  function owl_decryptRJ256($key,$iv,$string_to_decrypt)
  {
    $string_to_decrypt = base64_decode($string_to_decrypt);
    $rtn = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_decrypt, MCRYPT_MODE_CBC, $iv);
    $rtn = rtrim($rtn, "\0\4");
    return($rtn);
  }
}

//Disable Images
if ($vbo['owle_en'] AND $vbo['owle_noimages'])
{
  $vbu['showimages'] = 0;
}]]></phpcode>
		</plugin>
		<plugin active="1" executionorder="5">
			<title>Owl Encrypter - Get Key / Get Forums</title>
			<hookname>misc_start</hookname>
			<phpcode><![CDATA[if ($_REQUEST['do'] == 'getowlkey' AND $vbulletin->options['owle_autoconfig'])
{
  header('Content-Type: text/xml;');
  echo "<owl-encryptor><key>" . $vbulletin->options['owle_key'] . "</key><seed>" . $vbulletin->options['owle_salt'] . "</seed></owl-encryptor>";
  die();
}

if ($_REQUEST['do'] == 'getowlforums')
{
  global $vbulletin;
 
  //header('Content-Type: text/xml;');
  //$xml = new SimpleXMLElement('<root/>');
  //array_walk_recursive($vbulletin->forumcache, array ($xml, 'addChild'));
  //print $xml->asXML();
  echo "<pre>";

  echo "</pre>";
  die();
}]]></phpcode>
		</plugin>
		<plugin active="1" executionorder="10">
			<title>Owl Encrypter - Response Process</title>
			<hookname>replacement_vars</hookname>
			<phpcode><![CDATA[//This plugin will encrypt the entire reponse if the Owl Encrypter is enabled and an encrypted response is expected

global $vbulletin;
$vbo = &$vbulletin->options;

if ($vbo['owle_en'] AND ($_REQUEST['owle'] == 1 OR defined('OWL_ENCRYPTED')))
{
  $vbo['gzipoutput'] = false;
  $newtext = owl_encryptRJ256($vbo['owle_key'], $vbo['owle_salt'], $newtext);
}]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
		<phrasetype name="vBulletin Settings" fieldname="vbsettings">
			<phrase name="setting_owle_autoconfig_desc" date="1384432538" username="BirdOPrey5" version="1.0.0"><![CDATA[If yes the Owl client will auto-configure itself with the encryption key and salt when connecting to this forum. This makes it easy but does allow third parties to find the encryption key if they know where to look. If disabled you must provide the key and salt to Owl users by other means if you want to use encryption.]]></phrase>
			<phrase name="setting_owle_autoconfig_title" date="1384432538" username="BirdOPrey5" version="1.0.0"><![CDATA[Allow Encryption Auto Config?]]></phrase>
			<phrase name="setting_owle_en_desc" date="1374712616" username="BirdOPrey5" version="1.0.0"><![CDATA[Enable or disable the entire Owl Encrypter mod.]]></phrase>
			<phrase name="setting_owle_en_title" date="1374712616" username="BirdOPrey5" version="1.0.0"><![CDATA[Enable Owl Encrypter]]></phrase>
			<phrase name="setting_owle_key_desc" date="1374712694" username="BirdOPrey5" version="1.0.0"><![CDATA[The encryption key (must be identical  to the key used in Owl)]]></phrase>
			<phrase name="setting_owle_key_title" date="1374712694" username="BirdOPrey5" version="1.0.0"><![CDATA[Encryption Key]]></phrase>
			<phrase name="setting_owle_noimages_desc" date="1400685372" username="BirdOPrey5" version="1.0.0"><![CDATA[If Yes images will be disabled (pictures turned into links) when browsing with Owl Encryption enabled.]]></phrase>
			<phrase name="setting_owle_noimages_title" date="1400685372" username="BirdOPrey5" version="1.0.0"><![CDATA[Turn of Images]]></phrase>
			<phrase name="setting_owle_salt_desc" date="1374715458" username="BirdOPrey5" version="1.0.0"><![CDATA[The encryption salt (must be identical to the key used in Owl)]]></phrase>
			<phrase name="setting_owle_salt_title" date="1374715458" username="BirdOPrey5" version="1.0.0"><![CDATA[Encryption Salt]]></phrase>
			<phrase name="settinggroup_owlencrypter" date="1374712465" username="BirdOPrey5" version="1.0.0"><![CDATA[Owl Encrypter]]></phrase>
		</phrasetype>
	</phrases>
	<options>
		<settinggroup name="owlencrypter" displayorder="65535">
			<setting varname="owle_en" displayorder="10">
				<datatype>boolean</datatype>
				<optioncode>yesno</optioncode>
			</setting>
			<setting varname="owle_key" displayorder="20">
				<datatype>free</datatype>
			</setting>
			<setting varname="owle_salt" displayorder="30">
				<datatype>free</datatype>
			</setting>
			<setting varname="owle_autoconfig" displayorder="40">
				<datatype>boolean</datatype>
				<optioncode>yesno</optioncode>
				<defaultvalue>1</defaultvalue>
			</setting>
			<setting varname="owle_noimages" displayorder="50">
				<datatype>free</datatype>
				<optioncode>yesno</optioncode>
			</setting>
		</settinggroup>
	</options>
	<helptopics>
	</helptopics>
	<cronentries>
	</cronentries>
	<faqentries>
	</faqentries>
</product>
