Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+1 -1
View File
@@ -51,7 +51,7 @@
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php 268 2009-05-20 13:25:22Z bfarber $
* @version CVS: $Id: JSON.php 268 2009-05-20 13:25:45Z bfarber $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
<?php
class PEAR { }
+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
+865
View File
@@ -0,0 +1,865 @@
<?php
/**
* The Mail_mimeDecode class is used to decode mail/mime messages
*
* This class will parse a raw mime email and return
* the structure. Returned structure is similar to
* that returned by imap_fetchstructure().
*
* +----------------------------- IMPORTANT ------------------------------+
* | Usage of this class compared to native php extensions such as |
* | mailparse or imap, is slow and may be feature deficient. If available|
* | you are STRONGLY recommended to use the php extensions. |
* +----------------------------------------------------------------------+
*
* Compatible with PHP versions 4 and 5
*
* LICENSE: This LICENSE is in the BSD license style.
* Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org>
* Copyright (c) 2003-2006, PEAR <pear-group@php.net>
* 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 the authors, 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.
*
* @category Mail
* @package Mail_Mime
* @author Richard Heyes <richard@phpguru.org>
* @author George Schlossnagle <george@omniti.com>
* @author Cipriano Groenendal <cipri@php.net>
* @author Sean Coates <sean@php.net>
* @copyright 2003-2006 PEAR <pear-group@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version CVS: $Id: mimeDecode.php 288500 2009-09-21 05:32:32Z alan_k $
* @link http://pear.php.net/package/Mail_mime
*/
/**
* require PEAR
*
* This package depends on PEAR to raise errors.
*/
require_once 'PEAR.php';
/**
* The Mail_mimeDecode class is used to decode mail/mime messages
*
* This class will parse a raw mime email and return the structure.
* Returned structure is similar to that returned by imap_fetchstructure().
*
* +----------------------------- IMPORTANT ------------------------------+
* | Usage of this class compared to native php extensions such as |
* | mailparse or imap, is slow and may be feature deficient. If available|
* | you are STRONGLY recommended to use the php extensions. |
* +----------------------------------------------------------------------+
*
* @category Mail
* @package Mail_Mime
* @author Richard Heyes <richard@phpguru.org>
* @author George Schlossnagle <george@omniti.com>
* @author Cipriano Groenendal <cipri@php.net>
* @author Sean Coates <sean@php.net>
* @copyright 2003-2006 PEAR <pear-group@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://pear.php.net/package/Mail_mime
*/
class Mail_mimeDecode extends PEAR
{
/**
* The raw email to decode
*
* @var string
* @access private
*/
var $_input;
/**
* The header part of the input
*
* @var string
* @access private
*/
var $_header;
/**
* The body part of the input
*
* @var string
* @access private
*/
var $_body;
/**
* If an error occurs, this is used to store the message
*
* @var string
* @access private
*/
var $_error;
/**
* Flag to determine whether to include bodies in the
* returned object.
*
* @var boolean
* @access private
*/
var $_include_bodies;
/**
* Flag to determine whether to decode bodies
*
* @var boolean
* @access private
*/
var $_decode_bodies;
/**
* Flag to determine whether to decode headers
*
* @var boolean
* @access private
*/
var $_decode_headers;
/**
* Flag to determine whether to include attached messages
* as body in the returned object. Depends on $_include_bodies
*
* @var boolean
* @access private
*/
var $_rfc822_bodies;
/**
* Constructor.
*
* Sets up the object, initialise the variables, and splits and
* stores the header and body of the input.
*
* @param string The input to decode
* @access public
*/
function Mail_mimeDecode($input)
{
list($header, $body) = $this->_splitBodyHeader($input);
$this->_input = $input;
$this->_header = $header;
$this->_body = $body;
$this->_decode_bodies = false;
$this->_include_bodies = true;
$this->_rfc822_bodies = false;
}
/**
* Begins the decoding process. If called statically
* it will create an object and call the decode() method
* of it.
*
* @param array An array of various parameters that determine
* various things:
* include_bodies - Whether to include the body in the returned
* object.
* decode_bodies - Whether to decode the bodies
* of the parts. (Transfer encoding)
* decode_headers - Whether to decode headers
* input - If called statically, this will be treated
* as the input
* @return object Decoded results
* @access public
*/
function decode($params = null)
{
// determine if this method has been called statically
$isStatic = !(isset($this) && get_class($this) == __CLASS__);
// Have we been called statically?
// If so, create an object and pass details to that.
if ($isStatic AND isset($params['input'])) {
$obj = new Mail_mimeDecode($params['input']);
$structure = $obj->decode($params);
// Called statically but no input
} elseif ($isStatic) {
return PEAR::raiseError('Called statically and no input given');
// Called via an object
} else {
$this->_include_bodies = isset($params['include_bodies']) ?
$params['include_bodies'] : false;
$this->_decode_bodies = isset($params['decode_bodies']) ?
$params['decode_bodies'] : false;
$this->_decode_headers = isset($params['decode_headers']) ?
$params['decode_headers'] : false;
$this->_rfc822_bodies = isset($params['rfc_822bodies']) ?
$params['rfc_822bodies'] : false;
$structure = $this->_decode($this->_header, $this->_body);
if ($structure === false) {
$structure = $this->raiseError($this->_error);
}
}
return $structure;
}
/**
* Performs the decoding. Decodes the body string passed to it
* If it finds certain content-types it will call itself in a
* recursive fashion
*
* @param string Header section
* @param string Body section
* @return object Results of decoding process
* @access private
*/
function _decode($headers, $body, $default_ctype = 'text/plain')
{
$return = new stdClass;
$return->headers = array();
$headers = $this->_parseHeaders($headers);
foreach ($headers as $value) {
if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) {
$return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]);
$return->headers[strtolower($value['name'])][] = $value['value'];
} elseif (isset($return->headers[strtolower($value['name'])])) {
$return->headers[strtolower($value['name'])][] = $value['value'];
} else {
$return->headers[strtolower($value['name'])] = $value['value'];
}
}
reset($headers);
while (list($key, $value) = each($headers)) {
$headers[$key]['name'] = strtolower($headers[$key]['name']);
switch ($headers[$key]['name']) {
case 'content-type':
$content_type = $this->_parseHeaderValue($headers[$key]['value']);
if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) {
$return->ctype_primary = $regs[1];
$return->ctype_secondary = $regs[2];
}
if (isset($content_type['other'])) {
while (list($p_name, $p_value) = each($content_type['other'])) {
$return->ctype_parameters[$p_name] = $p_value;
}
}
break;
case 'content-disposition':
$content_disposition = $this->_parseHeaderValue($headers[$key]['value']);
$return->disposition = $content_disposition['value'];
if (isset($content_disposition['other'])) {
while (list($p_name, $p_value) = each($content_disposition['other'])) {
$return->d_parameters[$p_name] = $p_value;
}
}
break;
case 'content-transfer-encoding':
$content_transfer_encoding = $this->_parseHeaderValue($headers[$key]['value']);
break;
}
}
if (isset($content_type)) {
switch (strtolower($content_type['value'])) {
case 'text/plain':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null;
break;
case 'text/html':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null;
break;
case 'multipart/parallel':
case 'multipart/appledouble': // Appledouble mail
case 'multipart/report': // RFC1892
case 'multipart/signed': // PGP
case 'multipart/digest':
case 'multipart/alternative':
case 'multipart/related':
case 'multipart/mixed':
if(!isset($content_type['other']['boundary'])){
$this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
return false;
}
$default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain';
$parts = $this->_boundarySplit($body, $content_type['other']['boundary']);
for ($i = 0; $i < count($parts); $i++) {
list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]);
$part = $this->_decode($part_header, $part_body, $default_ctype);
if($part === false)
$part = $this->raiseError($this->_error);
$return->parts[] = $part;
}
break;
case 'message/rfc822':
if ($this->_rfc822_bodies) {
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body);
}
$obj = &new Mail_mimeDecode($body);
$return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
'decode_bodies' => $this->_decode_bodies,
'decode_headers' => $this->_decode_headers));
unset($obj);
break;
default:
if(!isset($content_transfer_encoding['value']))
$content_transfer_encoding['value'] = '7bit';
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $content_transfer_encoding['value']) : $body) : null;
break;
}
} else {
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body) : $body) : null;
}
return $return;
}
/**
* Given the output of the above function, this will return an
* array of references to the parts, indexed by mime number.
*
* @param object $structure The structure to go through
* @param string $mime_number Internal use only.
* @return array Mime numbers
*/
function &getMimeNumbers(&$structure, $no_refs = false, $mime_number = '', $prepend = '')
{
$return = array();
if (!empty($structure->parts)) {
if ($mime_number != '') {
$structure->mime_id = $prepend . $mime_number;
$return[$prepend . $mime_number] = &$structure;
}
for ($i = 0; $i < count($structure->parts); $i++) {
if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') {
$prepend = $prepend . $mime_number . '.';
$_mime_number = '';
} else {
$_mime_number = ($mime_number == '' ? $i + 1 : sprintf('%s.%s', $mime_number, $i + 1));
}
$arr = &Mail_mimeDecode::getMimeNumbers($structure->parts[$i], $no_refs, $_mime_number, $prepend);
foreach ($arr as $key => $val) {
$no_refs ? $return[$key] = '' : $return[$key] = &$arr[$key];
}
}
} else {
if ($mime_number == '') {
$mime_number = '1';
}
$structure->mime_id = $prepend . $mime_number;
$no_refs ? $return[$prepend . $mime_number] = '' : $return[$prepend . $mime_number] = &$structure;
}
return $return;
}
/**
* Given a string containing a header and body
* section, this function will split them (at the first
* blank line) and return them.
*
* @param string Input to split apart
* @return array Contains header and body section
* @access private
*/
function _splitBodyHeader($input)
{
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) {
return array($match[1], $match[2]);
}
$this->_error = 'Could not split header and body';
return false;
}
/**
* Parse headers given in $input and return
* as assoc array.
*
* @param string Headers to parse
* @return array Contains parsed headers
* @access private
*/
function _parseHeaders($input)
{
if ($input !== '') {
// Unfold the input
$input = preg_replace("/\r?\n/", "\r\n", $input);
$input = preg_replace("/\r\n(\t| )+/", ' ', $input);
$headers = explode("\r\n", trim($input));
foreach ($headers as $value) {
$hdr_name = substr($value, 0, $pos = strpos($value, ':'));
$hdr_value = substr($value, $pos+1);
if($hdr_value[0] == ' ')
$hdr_value = substr($hdr_value, 1);
$return[] = array(
'name' => $hdr_name,
'value' => $this->_decode_headers ? $this->_decodeHeader($hdr_value) : $hdr_value
);
}
} else {
$return = array();
}
return $return;
}
/**
* Function to parse a header value,
* extract first part, and any secondary
* parts (after ;) This function is not as
* robust as it could be. Eg. header comments
* in the wrong place will probably break it.
*
* @param string Header value to parse
* @return array Contains parsed result
* @access private
*/
function _parseHeaderValue($input)
{
if (($pos = strpos($input, ';')) !== false) {
$return['value'] = trim(substr($input, 0, $pos));
$input = trim(substr($input, $pos+1));
if (strlen($input) > 0) {
// This splits on a semi-colon, if there's no preceeding backslash
// Now works with quoted values; had to glue the \; breaks in PHP
// the regex is already bordering on incomprehensible
$splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/';
preg_match_all($splitRegex, $input, $matches);
$parameters = array();
for ($i=0; $i<count($matches[0]); $i++) {
$param = $matches[0][$i];
while (substr($param, -2) == '\;') {
$param .= $matches[0][++$i];
}
$parameters[] = $param;
}
for ($i = 0; $i < count($parameters); $i++) {
$param_name = trim(substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=')), "'\";\t\\ ");
$param_value = trim(str_replace('\;', ';', substr($parameters[$i], $pos + 1)), "'\";\t\\ ");
if (!empty($param_value[0]) && $param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}
$return['other'][$param_name] = $param_value;
$return['other'][strtolower($param_name)] = $param_value;
}
}
} else {
$return['value'] = trim($input);
}
return $return;
}
/**
* This function splits the input based
* on the given boundary
*
* @param string Input to parse
* @return array Contains array of resulting mime parts
* @access private
*/
function _boundarySplit($input, $boundary)
{
$parts = array();
$bs_possible = substr($boundary, 2, -2);
$bs_check = '\"' . $bs_possible . '\"';
if ($boundary == $bs_check) {
$boundary = $bs_possible;
}
$tmp = explode('--' . $boundary, $input);
for ($i = 1; $i < count($tmp) - 1; $i++) {
$parts[] = $tmp[$i];
}
return $parts;
}
/**
* Given a header, this function will decode it
* according to RFC2047. Probably not *exactly*
* conformant, but it does pass all the given
* examples (in RFC2047).
*
* @param string Input header value to decode
* @return string Decoded header value
* @access private
*/
function _decodeHeader($input)
{
// Remove white space between encoded-words
$input = preg_replace('/(=\?[^?]+\?(q|b)\?[^?]*\?=)(\s)+=\?/i', '\1=?', $input);
// For each encoded-word...
while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)/i', $input, $matches)) {
$encoded = $matches[1];
$charset = $matches[2];
$encoding = $matches[3];
$text = $matches[4];
switch (strtolower($encoding)) {
case 'b':
$text = base64_decode($text);
break;
case 'q':
$text = str_replace('_', ' ', $text);
preg_match_all('/=([a-f0-9]{2})/i', $text, $matches);
foreach($matches[1] as $value)
$text = str_replace('='.$value, chr(hexdec($value)), $text);
break;
}
$input = str_replace($encoded, $text, $input);
}
return $input;
}
/**
* Given a body string and an encoding type,
* this function will decode and return it.
*
* @param string Input body to decode
* @param string Encoding type to use.
* @return string Decoded body
* @access private
*/
function _decodeBody($input, $encoding = '7bit')
{
switch (strtolower($encoding)) {
case '7bit':
return $input;
break;
case 'quoted-printable':
return $this->_quotedPrintableDecode($input);
break;
case 'base64':
return base64_decode($input);
break;
default:
return $input;
}
}
/**
* Given a quoted-printable string, this
* function will decode and return it.
*
* @param string Input body to decode
* @return string Decoded body
* @access private
*/
function _quotedPrintableDecode($input)
{
// Remove soft line breaks
$input = preg_replace("/=\r?\n/", '', $input);
// Replace encoded characters
$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input);
return $input;
}
/**
* Checks the input for uuencoded files and returns
* an array of them. Can be called statically, eg:
*
* $files =& Mail_mimeDecode::uudecode($some_text);
*
* It will check for the begin 666 ... end syntax
* however and won't just blindly decode whatever you
* pass it.
*
* @param string Input body to look for attahcments in
* @return array Decoded bodies, filenames and permissions
* @access public
* @author Unknown
*/
function &uudecode($input)
{
// Find all uuencoded sections
preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches);
for ($j = 0; $j < count($matches[3]); $j++) {
$str = $matches[3][$j];
$filename = $matches[2][$j];
$fileperm = $matches[1][$j];
$file = '';
$str = preg_split("/\r?\n/", trim($str));
$strlen = count($str);
for ($i = 0; $i < $strlen; $i++) {
$pos = 1;
$d = 0;
$len=(int)(((ord(substr($str[$i],0,1)) -32) - ' ') & 077);
while (($d + 3 <= $len) AND ($pos + 4 <= strlen($str[$i]))) {
$c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20);
$c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20);
$c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20);
$c3 = (ord(substr($str[$i],$pos+3,1)) ^ 0x20);
$file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4));
$file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2));
$file .= chr(((($c2 - ' ') & 077) << 6) | (($c3 - ' ') & 077));
$pos += 4;
$d += 3;
}
if (($d + 2 <= $len) && ($pos + 3 <= strlen($str[$i]))) {
$c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20);
$c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20);
$c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20);
$file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4));
$file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2));
$pos += 3;
$d += 2;
}
if (($d + 1 <= $len) && ($pos + 2 <= strlen($str[$i]))) {
$c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20);
$c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20);
$file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4));
}
}
$files[] = array('filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $file);
}
return $files;
}
/**
* getSendArray() returns the arguments required for Mail::send()
* used to build the arguments for a mail::send() call
*
* Usage:
* $mailtext = Full email (for example generated by a template)
* $decoder = new Mail_mimeDecode($mailtext);
* $parts = $decoder->getSendArray();
* if (!PEAR::isError($parts) {
* list($recipents,$headers,$body) = $parts;
* $mail = Mail::factory('smtp');
* $mail->send($recipents,$headers,$body);
* } else {
* echo $parts->message;
* }
* @return mixed array of recipeint, headers,body or Pear_Error
* @access public
* @author Alan Knowles <alan@akbkhome.com>
*/
function getSendArray()
{
// prevent warning if this is not set
$this->_decode_headers = FALSE;
$headerlist =$this->_parseHeaders($this->_header);
$to = "";
if (!$headerlist) {
return $this->raiseError("Message did not contain headers");
}
foreach($headerlist as $item) {
$header[$item['name']] = $item['value'];
switch (strtolower($item['name'])) {
case "to":
case "cc":
case "bcc":
$to .= ",".$item['value'];
default:
break;
}
}
if ($to == "") {
return $this->raiseError("Message did not contain any recipents");
}
$to = substr($to,1);
return array($to,$header,$this->_body);
}
/**
* Returns a xml copy of the output of
* Mail_mimeDecode::decode. Pass the output in as the
* argument. This function can be called statically. Eg:
*
* $output = $obj->decode();
* $xml = Mail_mimeDecode::getXML($output);
*
* The DTD used for this should have been in the package. Or
* alternatively you can get it from cvs, or here:
* http://www.phpguru.org/xmail/xmail.dtd.
*
* @param object Input to convert to xml. This should be the
* output of the Mail_mimeDecode::decode function
* @return string XML version of input
* @access public
*/
function getXML($input)
{
$crlf = "\r\n";
$output = '<?xml version=\'1.0\'?>' . $crlf .
'<!DOCTYPE email SYSTEM "http://www.phpguru.org/xmail/xmail.dtd">' . $crlf .
'<email>' . $crlf .
Mail_mimeDecode::_getXML($input) .
'</email>';
return $output;
}
/**
* Function that does the actual conversion to xml. Does a single
* mimepart at a time.
*
* @param object Input to convert to xml. This is a mimepart object.
* It may or may not contain subparts.
* @param integer Number of tabs to indent
* @return string XML version of input
* @access private
*/
function _getXML($input, $indent = 1)
{
$htab = "\t";
$crlf = "\r\n";
$output = '';
$headers = @(array)$input->headers;
foreach ($headers as $hdr_name => $hdr_value) {
// Multiple headers with this name
if (is_array($headers[$hdr_name])) {
for ($i = 0; $i < count($hdr_value); $i++) {
$output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent);
}
// Only one header of this sort
} else {
$output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value, $indent);
}
}
if (!empty($input->parts)) {
for ($i = 0; $i < count($input->parts); $i++) {
$output .= $crlf . str_repeat($htab, $indent) . '<mimepart>' . $crlf .
Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) .
str_repeat($htab, $indent) . '</mimepart>' . $crlf;
}
} elseif (isset($input->body)) {
$output .= $crlf . str_repeat($htab, $indent) . '<body><![CDATA[' .
$input->body . ']]></body>' . $crlf;
}
return $output;
}
/**
* Helper function to _getXML(). Returns xml of a header.
*
* @param string Name of header
* @param string Value of header
* @param integer Number of tabs to indent
* @return string XML version of input
* @access private
*/
function _getXML_helper($hdr_name, $hdr_value, $indent)
{
$htab = "\t";
$crlf = "\r\n";
$return = '';
$new_hdr_value = ($hdr_name != 'received') ? Mail_mimeDecode::_parseHeaderValue($hdr_value) : array('value' => $hdr_value);
$new_hdr_name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $hdr_name)));
// Sort out any parameters
if (!empty($new_hdr_value['other'])) {
foreach ($new_hdr_value['other'] as $paramname => $paramvalue) {
$params[] = str_repeat($htab, $indent) . $htab . '<parameter>' . $crlf .
str_repeat($htab, $indent) . $htab . $htab . '<paramname>' . htmlspecialchars($paramname) . '</paramname>' . $crlf .
str_repeat($htab, $indent) . $htab . $htab . '<paramvalue>' . htmlspecialchars($paramvalue) . '</paramvalue>' . $crlf .
str_repeat($htab, $indent) . $htab . '</parameter>' . $crlf;
}
$params = implode('', $params);
} else {
$params = '';
}
$return = str_repeat($htab, $indent) . '<header>' . $crlf .
str_repeat($htab, $indent) . $htab . '<headername>' . htmlspecialchars($new_hdr_name) . '</headername>' . $crlf .
str_repeat($htab, $indent) . $htab . '<headervalue>' . htmlspecialchars($new_hdr_value['value']) . '</headervalue>' . $crlf .
$params .
str_repeat($htab, $indent) . '</header>' . $crlf;
return $return;
}
} // End of class
File diff suppressed because it is too large. Load diff
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ENTITY lt "&#38;#60;">
<!ENTITY gt "&#62;">
<!ENTITY amp "&#38;#38;">
<!ENTITY apos "&#39;">
<!ENTITY quot "&#34;">
<!ENTITY crlf "&#13;&#10;">
<!ELEMENT email (header+, (body | mimepart+))>
<!ELEMENT mimepart (header+, (body | mimepart+))>
<!ELEMENT body (#PCDATA)>
<!ELEMENT header ((headername|headervalue|parameter)*)>
<!ELEMENT headername (#PCDATA)>
<!ELEMENT headervalue (#PCDATA)>
<!ELEMENT parameter ((paramname|paramvalue)+)>
<!ELEMENT paramvalue (#PCDATA)>
<!ELEMENT paramname (#PCDATA)>
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:preserve-space elements="headervalue paramvalue body"/>
<xsl:template name="mimepart">
<xsl:variable name="boundary">
<xsl:for-each select="./header">
<xsl:if test="string(./headername) = 'Content-Type'">
<xsl:for-each select="./parameter">
<xsl:if test="string(./paramname) = 'boundary'">
<xsl:value-of select="paramvalue"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="header">
<xsl:value-of select="headername"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="headervalue"/>
<xsl:if test="count(./parameter) = 0">
<xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
<xsl:for-each select="parameter">
<xsl:text>;&#13;&#10;&#09;</xsl:text>
<xsl:value-of select="paramname"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="paramvalue"/>
<xsl:text>"</xsl:text>
</xsl:for-each>
<xsl:if test="count(./parameter) > 0">
<xsl:text>&#13;&#10;</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>&#13;&#10;</xsl:text>
<!-- Which to do, print a body or process subparts? -->
<xsl:choose>
<xsl:when test="count(./mimepart) = 0">
<xsl:value-of select="body"/>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="mimepart">
<xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>&#13;&#10;</xsl:text>
<xsl:call-template name="mimepart"/>
</xsl:for-each>
<xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>--&#13;&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- This is where the stylesheet really starts, matching the top level email element -->
<xsl:template match="email">
<xsl:call-template name="mimepart"/>
</xsl:template>
</xsl:stylesheet>
+7 -7
View File
@@ -6,10 +6,10 @@
* The original PHP version of this code was written by Geoffrey T. Dairiki
* <dairiki@dairiki.org>, and is used/adapted with his permission.
*
* $Horde: framework/Text_Diff/Diff.php,v 1.11.2.11 2008/02/24 10:57:46 jan Exp $
* $Horde: framework/Text_Diff/Diff.php,v 1.11.2.12 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -208,7 +208,7 @@ class Text_Diff {
* @param string $line The line to trim.
* @param integer $key The index of the line in the array. Not used.
*/
function trimNewlines(&$line, $key)
function trimNewlines(&$line, $key='')
{
$line = str_replace(array("\n", "\r"), '', $line);
}
@@ -380,7 +380,7 @@ class Text_Diff_Op_copy extends Text_Diff_Op {
function &reverse()
{
$reverse = new Text_Diff_Op_copy($this->final, $this->orig);
$reverse = &new Text_Diff_Op_copy($this->final, $this->orig);
return $reverse;
}
@@ -402,7 +402,7 @@ class Text_Diff_Op_delete extends Text_Diff_Op {
function &reverse()
{
$reverse = new Text_Diff_Op_add($this->orig);
$reverse = &new Text_Diff_Op_add($this->orig);
return $reverse;
}
@@ -424,7 +424,7 @@ class Text_Diff_Op_add extends Text_Diff_Op {
function &reverse()
{
$reverse = new Text_Diff_Op_delete($this->final);
$reverse = &new Text_Diff_Op_delete($this->final);
return $reverse;
}
@@ -446,7 +446,7 @@ class Text_Diff_Op_change extends Text_Diff_Op {
function &reverse()
{
$reverse = new Text_Diff_Op_change($this->final, $this->orig);
$reverse = &new Text_Diff_Op_change($this->final, $this->orig);
return $reverse;
}
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -18,9 +18,9 @@
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
* code was written by him, and is used/adapted with his permission.
*
* $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.4 2008/01/04 10:38:10 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.5 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -32,9 +32,22 @@ class Text_Diff_Engine_native {
function diff($from_lines, $to_lines)
{
array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
$_f = array();
$_t = array();
foreach( $from_lines as $l )
{
$_f[] = str_replace(array("\n", "\r"), '', $l);
}
foreach( $to_lines as $l )
{
$_t[] = str_replace(array("\n", "\r"), '', $l);
}
$from_lines = $_f;
$to_lines = $_t;
$n_from = count($from_lines);
$n_to = count($to_lines);
@@ -106,7 +119,7 @@ class Text_Diff_Engine_native {
++$yi;
}
if ($copy) {
$edits[] = new Text_Diff_Op_copy($copy);
$edits[] = &new Text_Diff_Op_copy($copy);
}
// Find deletes & adds.
@@ -121,11 +134,11 @@ class Text_Diff_Engine_native {
}
if ($delete && $add) {
$edits[] = new Text_Diff_Op_change($delete, $add);
$edits[] = &new Text_Diff_Op_change($delete, $add);
} elseif ($delete) {
$edits[] = new Text_Diff_Op_delete($delete);
$edits[] = &new Text_Diff_Op_delete($delete);
} elseif ($add) {
$edits[] = new Text_Diff_Op_add($add);
$edits[] = &new Text_Diff_Op_add($add);
}
}
@@ -5,9 +5,9 @@
* This class uses the Unix `diff` program via shell_exec to compute the
* differences between the two input arrays.
*
* $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -10,10 +10,10 @@
* echo $renderer->render($diff);
* </code>
*
* $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.5 2008/09/10 08:31:58 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.7 2009/07/24 13:04:43 jan Exp $
*
* Copyright 2005 Örjan Persson <o@42mm.org>
* Copyright 2005-2008 The Horde Project (http://www.horde.org/)
* Copyright 2005-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -39,6 +39,19 @@ class Text_Diff_Engine_string {
*/
function diff($diff, $mode = 'autodetect')
{
// Detect line breaks.
$lnbr = "\n";
if (strpos($diff, "\r\n") !== false) {
$lnbr = "\r\n";
} elseif (strpos($diff, "\r") !== false) {
$lnbr = "\r";
}
// Make sure we have a line break at the EOF.
if (substr($diff, -strlen($lnbr)) != $lnbr) {
$diff .= $lnbr;
}
if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') {
return PEAR::raiseError('Type of diff is unsupported');
}
@@ -56,7 +69,7 @@ class Text_Diff_Engine_string {
}
// Split by new line and remove the diff header, if there is one.
$diff = explode("\n", $diff);
$diff = explode($lnbr, $diff);
if (($mode == 'context' && strpos($diff[0], '***') === 0) ||
($mode == 'unified' && strpos($diff[0], '---') === 0)) {
array_shift($diff);
@@ -5,9 +5,9 @@
* This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff)
* to compute the differences between the two input arrays.
*
* $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.5 2009/07/24 13:06:24 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -42,17 +42,20 @@ class Text_Diff_Engine_xdiff {
* valid, albeit a little less descriptive and efficient. */
$edits = array();
foreach ($diff as $line) {
if (!strlen($line)) {
continue;
}
switch ($line[0]) {
case ' ':
$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
$edits[] = &new Text_Diff_Op_copy(array(substr($line, 1)));
break;
case '+':
$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
$edits[] = &new Text_Diff_Op_add(array(substr($line, 1)));
break;
case '-':
$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
$edits[] = &new Text_Diff_Op_delete(array(substr($line, 1)));
break;
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
/**
* $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Mapped.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -5,9 +5,9 @@
* This class renders the diff in classic diff format. It is intended that
* this class be customized via inheritance, to obtain fancier outputs.
*
* $Horde: framework/Text_Diff/Diff/Renderer.php,v 1.5.10.10 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer.php,v 1.5.10.12 2009/07/24 13:26:40 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -81,6 +81,7 @@ class Text_Diff_Renderer {
$output = $this->_startDiff();
$diffs = $diff->getDiff();
foreach ($diffs as $i => $edit) {
/* If these are unchanged (copied) lines, and we want to keep
* leading or trailing context lines, extract them from the copy
@@ -100,9 +101,10 @@ class Text_Diff_Renderer {
/* Create a new block with as many lines as we need
* for the trailing context. */
$context = array_slice($edit->orig, 0, $ntrail);
$block[] = new Text_Diff_Op_copy($context);
}
/* @todo */
$output .= $this->_block($x0, $ntrail + $xi - $x0,
$y0, $ntrail + $yi - $y0,
$block);
@@ -148,6 +150,7 @@ class Text_Diff_Renderer {
$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
foreach ($edits as $edit) {
switch (strtolower(get_class($edit))) {
case 'text_diff_op_copy':
$output .= $this->_context($edit->orig);
@@ -201,7 +204,7 @@ class Text_Diff_Renderer {
function _startBlock($header)
{
return $header . "\n";
return ( $header ) ? $header . "\n" : '';
}
function _endBlock()
@@ -4,9 +4,9 @@
*
* This class renders the diff in classic "context diff" format.
*
* $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.4 2009/01/06 15:23:42 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -2,9 +2,9 @@
/**
* "Inline" diff renderer.
*
* $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.14 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.16 2009/07/24 13:25:29 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -131,12 +131,14 @@ class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
/* We want to split on word boundaries, but we need to
* preserve whitespace as well. Therefore we split on words,
* but include all blocks of whitespace in the wordlist. */
$diff = new Text_Diff($this->_splitOnWords($text1, $nl),
$this->_splitOnWords($text2, $nl));
$diff = new Text_Diff('native',
array($this->_splitOnWords($text1, $nl),
$this->_splitOnWords($text2, $nl)));
/* Get the diff in inline format. */
$renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),
array('split_level' => 'words')));
$renderer = new Text_Diff_Renderer_inline
(array_merge($this->getParams(),
array('split_level' => 'words')));
/* Run the diff and get the output. */
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
@@ -0,0 +1,68 @@
<?php
/**
* "Unified" diff renderer.
*
* This class renders the diff in classic "unified diff" format.
*
* $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.7 2009/01/06 15:23:42 jan Exp $
*
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Ciprian Popovici
* @package Text_Diff
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
/**
* @package Text_Diff
*/
class Text_Diff_Renderer_ips3waymerge extends Text_Diff_Renderer {
/**
* Number of leading context "lines" to preserve.
*/
var $_leading_context_lines = 10000;
/**
* Number of trailing context "lines" to preserve.
*/
var $_trailing_context_lines = 10000;
function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
{
if ($xlen != 1) {
$xbeg .= ',' . $xlen;
}
if ($ylen != 1) {
$ybeg .= ',' . $ylen;
}
//return "@@ -$xbeg +$ybeg @@";
}
function _context($lines)
{
return $this->_lines($lines, ' ');
}
function _added($lines)
{
return $this->_lines($lines, '+');
}
function _deleted($lines)
{
return $this->_lines($lines, '-');
}
function _changed($orig, $final)
{
return $this->_deleted($orig) . $this->_added($final);
}
}
@@ -0,0 +1,115 @@
<?php
/**
* "Inline" diff renderer.
*
* $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.16 2009/07/24 13:25:29 jan Exp $
*
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Ciprian Popovici
* @package Text_Diff
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
/**
* "Inline" diff renderer.
*
* This class renders diffs in the Wiki-style "inline" format.
*
* @author Ciprian Popovici
* @package Text_Diff
*/
class Text_Diff_Renderer_ipsunified extends Text_Diff_Renderer {
/**
* Number of leading context "lines" to preserve.
*/
var $_leading_context_lines = 10000;
/**
* Number of trailing context "lines" to preserve.
*/
var $_trailing_context_lines = 10000;
/**
* Prefix for inserted text.
*/
var $_ins_prefix = '<ins>';
/**
* Suffix for inserted text.
*/
var $_ins_suffix = '</ins>';
/**
* Prefix for deleted text.
*/
var $_del_prefix = '<del>';
/**
* Suffix for deleted text.
*/
var $_del_suffix = '</del>';
/**
* Header for each change block.
*/
var $_block_header = '';
/**
* What are we currently splitting on? Used to recurse to show word-level
* changes.
*/
var $_split_level = 'lines';
function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
{
return $this->_block_header;
}
function _startBlock($header)
{
return $header;
}
function _lines($lines, $prefix = ' ', $encode = true)
{
if ($encode) {
array_walk($lines, array(&$this, '_encode'));
}
return implode("\n", $lines) . "\n";
}
function _added($lines)
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_ins_prefix . $lines[0];
$lines[count($lines) - 1] .= $this->_ins_suffix;
return $this->_lines($lines, ' ', false);
}
function _deleted($lines, $words = false)
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_del_prefix . $lines[0];
$lines[count($lines) - 1] .= $this->_del_suffix;
return $this->_lines($lines, ' ', false);
}
function _changed($orig, $final)
{
return $this->_deleted($orig) . $this->_added($final);
}
function _encode(&$string)
{
$string = htmlspecialchars($string);
}
}
@@ -4,9 +4,9 @@
*
* This class renders the diff in classic "unified diff" format.
*
* $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.6 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.7 2009/01/06 15:23:42 jan Exp $
*
* Copyright 2004-2008 The Horde Project (http://www.horde.org/)
* Copyright 2004-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -2,9 +2,9 @@
/**
* A class for computing three way diffs.
*
* $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $
* $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -57,7 +57,7 @@ class Text_Diff_ThreeWay extends Text_Diff {
$lines = array();
foreach ($this->_edits as $edit) {
if ($edit->isConflict()) {
/* FIXME: this should probably be moved somewhere else. */
$lines = array_merge($lines,
array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')),
$edit->final1,
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+6 -4
View File
@@ -2,9 +2,9 @@
/**
* A class for computing three way diffs.
*
* $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.6 2008/01/04 10:37:26 jan Exp $
* $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.7 2009/01/06 15:23:41 jan Exp $
*
* Copyright 2007-2008 The Horde Project (http://www.horde.org/)
* Copyright 2007-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
@@ -41,11 +41,13 @@ class Text_Diff3 extends Text_Diff {
function Text_Diff3($orig, $final1, $final2)
{
if (extension_loaded('xdiff')) {
require_once 'Text/Diff/Engine/xdiff.php';
$engine = new Text_Diff_Engine_xdiff();
} else {
require_once 'Text/Diff/Engine/native.php';
$engine = new Text_Diff_Engine_native();
}
$this->_edits = $this->_diff3($engine->diff($orig, $final1),
$engine->diff($orig, $final2));
}
@@ -57,7 +59,7 @@ class Text_Diff3 extends Text_Diff {
$lines = array();
foreach ($this->_edits as $edit) {
if ($edit->isConflict()) {
/* FIXME: this should probably be moved somewhere else. */
$lines = array_merge($lines,
array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')),
$edit->final1,
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+97 -51
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.7.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<?xml version="1.0" encoding="ISO-8859-1"?>
<package packagerversion="1.8.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Text_Diff</name>
<channel>pear.php.net</channel>
<summary>Engine for performing and rendering text diffs</summary>
@@ -22,10 +22,10 @@
<email>pmjones@memphis.edu</email>
<active>no</active>
</lead>
<date>2008-09-10</date>
<time>10:52:52</time>
<date>2009-07-24</date>
<time>15:35:25</time>
<version>
<release>1.1.0</release>
<release>1.1.1</release>
<api>1.1.0</api>
</version>
<stability>
@@ -33,21 +33,23 @@
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Add countAddedLines() and countDeletedLines() methods (Christian King, PEAR Request #13183).
* Improve string engine if patch data has no header (PEAR Bug #14533).
* Fix autodetection of diff type in string engine (PEAR Bug #14625).</notes>
<notes>
* Make sure that the diff string ends with a line break (PEAR Bug #14533).
* Fix notices if xdiff engine creates empty lines (PEAR Bug #16240).
* Fix inline renderer if xdiff extension is installed.
</notes>
<contents>
<dir name="/">
<file baseinstalldir="/Text" md5sum="b30ce3240eed85e2114b93e28095af90" name="Diff/Engine/native.php" role="php" />
<file baseinstalldir="/Text" md5sum="4ccb7b5ea80041fcd6e5c5cd958931fa" name="Diff/Engine/shell.php" role="php" />
<file baseinstalldir="/Text" md5sum="1daaca651ed46e5711b43e47e91e077f" name="Diff/Engine/string.php" role="php" />
<file baseinstalldir="/Text" md5sum="05f00fc5c59664199eb533ff825a386c" name="Diff/Engine/xdiff.php" role="php" />
<file baseinstalldir="/Text" md5sum="1263babf64df086001944b699014e59d" name="Diff/Renderer/context.php" role="php" />
<file baseinstalldir="/Text" md5sum="e001548ef0b37702633a421cf7eed83d" name="Diff/Renderer/inline.php" role="php" />
<file baseinstalldir="/Text" md5sum="c4dbae31ce515995100f6ad27a8c9c4e" name="Diff/Renderer/unified.php" role="php" />
<file baseinstalldir="/Text" md5sum="96b1dc3ba33aba32a4b5662b22d8b58a" name="Diff/Mapped.php" role="php" />
<file baseinstalldir="/Text" md5sum="d5ac2cccaacad465caa41fae23eae8ad" name="Diff/Renderer.php" role="php" />
<file baseinstalldir="/Text" md5sum="abf74995fef0ba23d50dfc6a5652b5e1" name="Diff/ThreeWay.php" role="php" />
<file baseinstalldir="/Text" md5sum="07b505d89a268efb62e4ea69a8817d56" name="Diff/Engine/native.php" role="php" />
<file baseinstalldir="/Text" md5sum="79d9fc2603418ba25753b1e035696e90" name="Diff/Engine/shell.php" role="php" />
<file baseinstalldir="/Text" md5sum="746c18001d2e7968f693faa73521d650" name="Diff/Engine/string.php" role="php" />
<file baseinstalldir="/Text" md5sum="b597d4f5e0ba0f743d0a60a7de99fe50" name="Diff/Engine/xdiff.php" role="php" />
<file baseinstalldir="/Text" md5sum="c73de903cd1e0026e4edfc766d2e65ac" name="Diff/Renderer/context.php" role="php" />
<file baseinstalldir="/Text" md5sum="15f8e4e1d9661e73812281b010ad76ac" name="Diff/Renderer/inline.php" role="php" />
<file baseinstalldir="/Text" md5sum="fb409e01619612671a6011d60f8017ed" name="Diff/Renderer/unified.php" role="php" />
<file baseinstalldir="/Text" md5sum="8d3c0a7cc6bfd629b06b689809296a90" name="Diff/Mapped.php" role="php" />
<file baseinstalldir="/Text" md5sum="26048a82f49161c82cc92922c7d7a8aa" name="Diff/Renderer.php" role="php" />
<file baseinstalldir="/Text" md5sum="6d967016ce09fca862199d41719c06d8" name="Diff/ThreeWay.php" role="php" />
<file baseinstalldir="/Text" md5sum="5fbdf5388905ed07026b876126aeee5a" name="docs/examples/1.txt" role="doc" />
<file baseinstalldir="/Text" md5sum="011c4dad4506a4843ded1f12cab69909" name="docs/examples/2.txt" role="doc" />
<file baseinstalldir="/Text" md5sum="6082891c438ee1ba70fd89b9b4e241e8" name="docs/examples/diff.php" role="doc" />
@@ -58,21 +60,22 @@
<file baseinstalldir="/Text" md5sum="ea33106f5d970bf5dc318b752c95e343" name="tests/5.txt" role="test" />
<file baseinstalldir="/Text" md5sum="38f7931505de496d7312a830b2880f2c" name="tests/6.txt" role="test" />
<file baseinstalldir="/Text" md5sum="aa40a9c049e89eb8c6f5b0f47e1aabd9" name="tests/context.patch" role="test" />
<file baseinstalldir="/Text" md5sum="b0143ef7d5e9a1ace0ff747165f27c1f" name="tests/context.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="2a88e4c49d51bbdced9a4bd8a8a657c5" name="tests/context2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="43e8b69ff75bc0e7ecab5b4e87827d19" name="tests/diff.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="2c2f13e357f691f3922d07f6e70fa43d" name="tests/inline.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="05e94365c047905009b1913a3600036f" name="tests/inline2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="e05b5cf54cfaf541663fa802724e9549" name="tests/pear_bug12740.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="7949426acc1e64d6c10338bf6382257d" name="tests/pear_bug4879.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="7fb3cda23ca78409f72ac233784ff1a1" name="tests/pear_bug6251.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="c4d40a654a584d3f939dca33fff0a5c4" name="tests/pear_bug6428.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="01f878ee632292a12de6c0facec486b0" name="tests/context.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="2e9288b5ef4a7804b40470bdd4bc64f5" name="tests/context2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="7f694063eaddfb3eeb9c1adef929a70e" name="tests/diff.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="2b4e2bcd033ca9a6098c6672a21c1f2f" name="tests/inline.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="fa7a6ac0ceacf68c1d7e6a121f23f275" name="tests/inline2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="e70ad292ff86d2173d002945a3c7c706" name="tests/pear_bug12740.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="3bf51765e10607c7bcfc5ee6a898ff9f" name="tests/pear_bug4879.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="81a86e4b7950ad48b47dc681a8c13fe4" name="tests/pear_bug6251.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="c11639b0af5c2967294648d9bfb4ed6d" name="tests/pear_bug6428.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="e7011d4030f4a020d24efb6f1673a1bc" name="tests/string.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="359096964862ff26e28cc44609ca237f" name="tests/unified.patch" role="test" />
<file baseinstalldir="/Text" md5sum="77977a033a539c5ccadaf728b95a1a2c" name="tests/unified.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="dab2830cf62f341f1046b883948c1851" name="tests/unified2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="3f715ec0e86162bddc1ea794a04aa4d3" name="Diff.php" role="php" />
<file baseinstalldir="/Text" md5sum="7b57773de584d2408214cb2c7a0d0a2e" name="Diff3.php" role="php" />
<file baseinstalldir="/Text" md5sum="42e165a1069c23cedb08ac9161dd5872" name="tests/unified.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="f634a746992d4202584f0ec4b92712d1" name="tests/unified2.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="e28b61e4a41681a1fd11fc539c99feff" name="tests/xdiff.phpt" role="test" />
<file baseinstalldir="/Text" md5sum="456537f75ca3421a08e1407d014774de" name="Diff.php" role="php" />
<file baseinstalldir="/Text" md5sum="7bc9fb4108713e94bbeaea940f134bd0" name="Diff3.php" role="php" />
</dir>
</contents>
<dependencies>
@@ -92,6 +95,23 @@
</dependencies>
<phprelease />
<changelog>
<release>
<date>2008-09-10</date>
<version>
<release>1.1.0</release>
<api>1.1.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>
* Add countAddedLines() and countDeletedLines() methods (Christian King, PEAR Request #13183).
* Improve string engine if patch data has no header (PEAR Bug #14533).
* Fix autodetection of diff type in string engine (PEAR Bug #14625).
</notes>
</release>
<release>
<version>
<release>1.0.0</release>
@@ -103,7 +123,9 @@
</stability>
<date>2008-01-31</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Stable release; final non-bugfix PHP 4 release.</notes>
<notes>
* Stable release; final non-bugfix PHP 4 release.
</notes>
</release>
<release>
<version>
@@ -116,7 +138,9 @@
</stability>
<date>2007-01-04</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fixed assertion in the native engine with PHP 5 (PEAR Bug #12740).</notes>
<notes>
* Fixed assertion in the native engine with PHP 5 (PEAR Bug #12740).
</notes>
</release>
<release>
<version>
@@ -129,8 +153,10 @@
</stability>
<date>2007-10-28</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fixed off-by-one errors with line numbers in default renderer output (Milian Wolff, PEAR Bugs #7839, #12111).
* Restore compatibility with PHP 4 in the shell diff engine.</notes>
<notes>
* Fixed off-by-one errors with line numbers in default renderer output (Milian Wolff, PEAR Bugs #7839, #12111).
* Restore compatibility with PHP 4 in the shell diff engine.
</notes>
</release>
<release>
<version>
@@ -143,11 +169,13 @@
</stability>
<date>2007-09-20</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Converted to package.xml 2.0.
<notes>
* Converted to package.xml 2.0.
* Added context diff renderer.
* Stripped nul characters to avoid infinite loops (PEAR Bug #7921).
* Fix assertion with PHP 5 (PEAR Bug #10423).
* Add shell diff engine (Milian Wolff, PEAR Request #12051).</notes>
* Add shell diff engine (Milian Wolff, PEAR Request #12051).
</notes>
</release>
<release>
<version>
@@ -160,7 +188,9 @@
</stability>
<date>2006-02-06</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fix Text_Diff::reverse() method with PHP 5 (PEAR Bug #6699).</notes>
<notes>
* Fix Text_Diff::reverse() method with PHP 5 (PEAR Bug #6699).
</notes>
</release>
<release>
<version>
@@ -173,10 +203,12 @@
</stability>
<date>2006-01-06</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fix reference warnings with PHP 4.4 and PHP 5.1.
<notes>
* Fix reference warnings with PHP 4.4 and PHP 5.1.
* Fix too many trailing context lines for the last diff chunk. (PEAR Bug #6251).
* Add diff engine for existing diffs/patches (Örjan Persson, PEAR Request #5373).
* Fix problems with numbers, whitespace-only changes and the inline renderer (PEAR Bug #6428.</notes>
* Add diff engine for existing diffs/patches (Örjan Persson, PEAR Request #5373).
* Fix problems with numbers, whitespace-only changes and the inline renderer (PEAR Bug #6428.
</notes>
</release>
<release>
<version>
@@ -189,7 +221,9 @@
</stability>
<date>2005-08-19</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Restore compatibility with PHP 4.2.0 (PEAR Bug #5152).</notes>
<notes>
* Restore compatibility with PHP 4.2.0 (PEAR Bug #5152).
</notes>
</release>
<release>
<version>
@@ -202,9 +236,11 @@
</stability>
<date>2005-08-16</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fix Renderer::getParams() (PEAR Bug #4549)
<notes>
* Fix Renderer::getParams() (PEAR Bug #4549)
* Encode HTML entities in the inline renderer (Horde Bug #2181)
* Fix endless loop in inline renderer with certain whitespaces (PEAR Bug #4879)</notes>
* Fix endless loop in inline renderer with certain whitespaces (PEAR Bug #4879)
</notes>
</release>
<release>
<version>
@@ -217,10 +253,12 @@
</stability>
<date>2005-05-04</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Fixed variable name in Text_MappedDiff.
<notes>
* Fixed variable name in Text_MappedDiff.
* Removed output buffering code.
* Fixed additional empty lines being added with the inline renderer (Bug 3730).
* Fixed multiple calls to _endBlock per block (Bug 4065).</notes>
* Fixed multiple calls to _endBlock per block (Bug 4065).
</notes>
</release>
<release>
<version>
@@ -233,10 +271,12 @@
</stability>
<date>2004-10-13</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>* Generalized Diff Renderer parameter handling.
<notes>
* Generalized Diff Renderer parameter handling.
* Added an inline renderer contributed by Ciprian Popovici (ciprian@zuavra.net).
* Fixed PHPDoc.
* Fixed a PHP 5 incompatibility.</notes>
* Fixed a PHP 5 incompatibility.
</notes>
</release>
<release>
<version>
@@ -249,7 +289,9 @@
</stability>
<date>2004-05-13</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>Renamed final() and orig() methods to avoid conflict with final keyword in PHP5</notes>
<notes>
Renamed final() and orig() methods to avoid conflict with final keyword in PHP5
</notes>
</release>
<release>
<version>
@@ -262,7 +304,9 @@
</stability>
<date>2004-03-16</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>Added optional xdiff support</notes>
<notes>
Added optional xdiff support
</notes>
</release>
<release>
<version>
@@ -275,7 +319,9 @@
</stability>
<date>2004-01-09</date>
<license uri="http://opensource.org/licenses/lgpl-license.php">LGPL</license>
<notes>Initial package release</notes>
<notes>
Initial package release
</notes>
</release>
</changelog>
</package>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+81 -42
View File
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* AJAX input parsing and handling
* Last Updated: $Date: 2009-10-23 21:23:15 -0400 (Fri, 23 Oct 2009) $
* Last Updated: $Date: 2010-10-14 13:11:17 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 341 $
* @version $Revision: 477 $
*/
@@ -22,7 +24,6 @@ class classAjax
* XML output
*
* @var string Output
* @access public
*/
public $xml_output;
@@ -30,7 +31,6 @@ class classAjax
* XML Header
*
* @var string XML doctype
* @access public
*/
public $xml_header;
@@ -38,9 +38,8 @@ class classAjax
* Character sets
*
* @var array Charsets supported by html_entity_decode
* @access private
*/
private $decodeCharsets = array( 'iso-8859-1' => 'ISO-8859-1',
private $decodeCharsets = array('iso-8859-1' => 'ISO-8859-1',
'iso8859-1' => 'ISO-8859-1',
'iso-8859-15' => 'ISO-8859-15',
'iso8859-15' => 'ISO-8859-15',
@@ -67,7 +66,6 @@ class classAjax
/**
* Constructor
*
* @access public
* @return void
*/
public function __construct()
@@ -78,10 +76,18 @@ class classAjax
}
$this->xml_header = "<?xml version=\"1.0\" encoding=\"" . IPS_DOC_CHAR_SET . "\"?".'>';
/* Convert incoming $_POST fields */
array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertCharsets( IPSText::convertUnicode($value), "utf-8", "' . IPS_DOC_CHAR_SET . '" );' ) );
//-----------------------------------------
// Using this code allows characters that ARE supported
// within the character set to be recoded properly, instead
// of as HTML entities when submitted via AJAX. The problem is,
// any characters NOT supported in the charset are corrupted. :-\
//-----------------------------------------
//array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertCharsets( IPSText::convertUnicode($value, true), "utf-8", "' . IPS_DOC_CHAR_SET . '" );' ) );
// We use $_REQUEST in a lot of places, so we might need to do this, but based on the below comments I'll leave this
// commented out for now...
//array_walk_recursive( $_REQUEST, create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
@@ -94,7 +100,6 @@ class classAjax
/**
* Convert and make safe an incoming string
*
* @access public
* @param string Raw input string
* @param boolean Run through parse_incoming routine
* @return string Cleaned string
@@ -102,6 +107,18 @@ class classAjax
public function convertAndMakeSafe( $value, $parse_incoming=true )
{
$value = rawurldecode( $value );
//-----------------------------------------
// \ char is passed as %5C so it won't be double
// escaped if magic quotes is on - do it manually
// @link http://community.invisionpower.com/tracker/issue-24971-status-update-issue/
//-----------------------------------------
if( IPS_MAGIC_QUOTES )
{
$value = str_replace( "\\", "\\\\", $value );
}
$value = $this->convertUnicode( $value );
$value = $this->convertHtmlEntities( $value );
@@ -112,11 +129,29 @@ class classAjax
return $value;
}
/**
* Cleans output so it is suitable for printing
*
* @param string Output data
* @return string Output data with parsed macros
*/
public function cleanOutput( $string )
{
if ( ! IN_ACP )
{
$string = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $string );
}
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
return $string;
}
/**
* Print an error
*
* @access public
* @return void [Outputs XML document and exits]
*/
public function returnGenericError()
@@ -135,7 +170,6 @@ class classAjax
/**
* Return a NULL result
*
* @access public
* @param mixed Value to send
* @return void [Outputs XML document and exits]
*/
@@ -144,6 +178,8 @@ class classAjax
@header( "Content-type: text/xml" );
$this->printNocacheHeaders();
$val = $this->parseAndCleanHooks( $val );
print $this->xml_header . "\r\n<null>{$val}</null>";
exit();
}
@@ -151,7 +187,6 @@ class classAjax
/**
* Return a string
*
* @access public
* @param string String to output
* @return void [Outputs plaintext string]
*/
@@ -159,31 +194,21 @@ class classAjax
{
@header( "Content-type: text/plain;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
print $string;
echo $this->parseAndCleanHooks( $string );
exit();
}
/**
* Return a JSON error message
*
* @access public
* @param string Error message
* @return void [Outputs JSON string and exits]
*/
public function returnJsonError( $message )
{
$message = addslashes( $message );
@header( "Content-type: application/json;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
print <<<EOF
{
'error' : "{$message}"
}
EOF;
exit();
/* Just alias it... */
$this->returnJsonArray( array( 'error' => $message ) );
}
/**
@@ -210,7 +235,6 @@ EOF;
/**
* Return HTML content
*
* @access public
* @param string HTML to output
* @return void [Outputs HTML and exits]
*/
@@ -219,9 +243,8 @@ EOF;
//-----------------------------------------
// Stop one from removing cookie protection
//-----------------------------------------
$string = ( $string ) ? $string : '<!--nothing-->';
$string = str_ireplace( "htmldocument.prototype", "HTMLDocument_prototype", $string );
// Fix IE bugs
$string = str_ireplace( "&sect", "&amp;sect", $string );
@@ -231,9 +254,14 @@ EOF;
$string = str_replace( "ì", "&#8220;", $string );
$string = str_replace( "î", "&#8221;", $string );
}
// Other stuff
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
if ( ! IN_ACP )
{
$string = $this->parseAndCleanHooks( $string );
}
@header( "Content-type: text/html;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
@@ -242,10 +270,23 @@ EOF;
exit();
}
/**
* Run hooks and remove hook comments
*
* @param string $string
* @return string
*/
public function parseAndCleanHooks( $string )
{
$string = ipsRegistry::getClass('output')->templateHooks( $string );
$string = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $string );
return $string;
}
/**
* Print nocache headers
*
* @access public
* @return void [Outputs headers]
*/
public function printNocacheHeaders()
@@ -267,7 +308,6 @@ EOF;
/**
* Convert AJAX unicode to standard char codes
*
* @access public
* @param string Input to convert
* @return string UTF-8 Converted content
*/
@@ -282,7 +322,6 @@ EOF;
/**
* Convert HTML entities into raw characters
*
* @access public
* @param string Input to convert
* @return string HTML entity decoded content
*/
@@ -292,7 +331,7 @@ EOF;
// Try and fix up HTML entities with missing ;
//-----------------------------------------
$t = preg_replace( "/&#(\d+?)([^\d;])/i", "&#\\1;\\2", $t );
$t = preg_replace( '/&#(\d+?)([^\d;])/i', "&#\\1;\\2", $t );
//-----------------------------------------
// Continue...
@@ -332,4 +371,4 @@ EOF;
return $t;
}
}
}
+143 -149
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class can act as an API server, handling API requests
* Last Updated: $Date: 2009-10-01 10:02:41 -0400 (Thu, 01 Oct 2009) $
* Last Updated: $Date: 2010-08-20 17:38:30 -0400 (Fri, 20 Aug 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 6th January 2006 (12:24)
* @version $Revision: 334 $
* @version $Revision: 450 $
*
* Examples of sending and receiving API data
* <code>
@@ -43,109 +46,109 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
class classApiServer
{
/**
* XML-RPC class
*
* @access public
* @var object
*/
* XML-RPC class
*
* @access public
* @var object
*/
public $xmlrpc;
/**
* Raw incoming data
*
* @access private
* @var string
*/
* Raw incoming data
*
* @access private
* @var string
*/
public $raw_request;
/**
* Requested method name
*
* @access private
* @var string
*/
* Requested method name
*
* @access private
* @var string
*/
private $method_name;
/**
* Raw data incoming
*
* @access private
* @var string
*/
* Raw data incoming
*
* @access private
* @var string
*/
private $_raw_in_data;
/**
* Raw data output
*
* @access private
* @var string
*/
* Raw data output
*
* @access private
* @var string
*/
private $_raw_out_data;
/**
* Method params
*
* @access public
* @var array
*/
* Method params
*
* @access public
* @var array
*/
public $params = array();
/**
* XML-RPC serialized 64 key
*
* @access private
* @var string
*/
* XML-RPC serialized 64 key
*
* @access private
* @var string
*/
private $serialized_key = '__serialized64__';
/**
* Server function object
*
* @access private
* @var object
*/
* Server function object
*
* @access private
* @var object
*/
private $xml_server;
/**
* Return cookie information
*
* @access public
* @var array
*/
* Return cookie information
*
* @access public
* @var array
*/
public $cookies = array();
/**
* XML-RPC cookie serialized 64 key
*
* @access private
* @var string
*/
* XML-RPC cookie serialized 64 key
*
* @access private
* @var string
*/
private $cookie_serialized_key = '__cookie__serialized64__';
/**
* HTTP Auth required
*
* @access public
* @var string
* @var string
*/
/**#@+
* HTTP Auth required
*
* @access public
* @var string
*/
public $auth_user = '';
public $auth_pass = '';
/*#@-*/
/**
* Errors array
*
* @access public
* @var array
*/
* Errors array
*
* @access public
* @var array
*/
public $errors = array();
/**
* Constructor
*
* @access public
* @return void
*/
* Constructor
*
* @access public
* @return void
*/
public function __construct()
{
if ( ! is_object( $this->xmlrpc ) )
@@ -158,24 +161,17 @@ class classApiServer
}
/**
* Add object map to this class
*
* @access public
* @param string Incoming data
* @return string api
*/
* Add object map to this class
*
* @access public
* @param string Incoming data
* @return string api
*/
public function decodeRequest( $incoming='' )
{
if ( ! $incoming )
{
# PHP Bug: http://bugs.php.net/bug.php?id=41293
if( phpversion() == "5.2.2" )
{
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents( "php://input" );
}
$incoming = isset( $GLOBALS['HTTP_RAW_POST_DATA'] ) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$incoming = file_get_contents( "php://input" );
}
//-----------------------------------------
@@ -225,12 +221,12 @@ class classApiServer
}
/**
* Get the XML-RPC data
*
* @access public
* @param string Incoming data
* @return mixed Boolean, Output error
*/
* Get the XML-RPC data
*
* @access public
* @param string Incoming data
* @return mixed Boolean, Output error
*/
public function getXmlRpc( $incoming='' )
{
if ( ! $this->xml_server )
@@ -306,12 +302,12 @@ class classApiServer
}
/**
* Set a cookie for the API request
*
* @access public
* @param array Array of params to send
* @return void
*/
* Set a cookie for the API request
*
* @access public
* @param array Array of params to send
* @return void
*/
public function apiAddCookieData( $data )
{
if ( $data['name'] )
@@ -321,14 +317,14 @@ class classApiServer
}
/**
* Return API Request
*
* @access public
* @param array Array of params to send
* @param int Complex data: Encode before sending
* @param array Forced data type mapping
* @return void
*/
* Return API Request
*
* @access public
* @param array Array of params to send
* @param int Complex data: Encode before sending
* @param array Forced data type mapping
* @return void
*/
public function apiSendReply( $data=array(), $complex_data=0, $force=array() )
{
//-----------------------------------------
@@ -387,25 +383,25 @@ class classApiServer
}
/**
* Return API Request (ERROR)
*
* @access public
* @param int Error Code
* @param string Error message
* @return void
*/
* Return API Request (ERROR)
*
* @access public
* @param int Error Code
* @param string Error message
* @return void
*/
public function apiSendError( $error_code, $error_msg )
{
$this->xmlrpc->returnError( $error_code, $error_msg );
}
/**
* Decode API Request
*
* @access public
* @param string Raw data picked up
* @return void
*/
* Decode API Request
*
* @access public
* @param string Raw data picked up
* @return void
*/
public function apiDecodeRequest( $raw_data )
{
//-----------------------------------------
@@ -422,15 +418,15 @@ class classApiServer
}
/**
* Send API Request
*
* @access public
* @param string URL to send request to
* @param string Method name for API to pick up
* @param array Data to send
* @param int Complex data: Encode before sending
* @return boolean Data sent successfully
*/
* Send API Request
*
* @access public
* @param string URL to send request to
* @param string Method name for API to pick up
* @param array Data to send
* @param int Complex data: Encode before sending
* @return boolean Data sent successfully
*/
public function apiSendRequest( $url, $method_name, $data=array(), $complex_data=0 )
{
//-----------------------------------------
@@ -487,12 +483,12 @@ class classApiServer
}
/**
* Process returned data
*
* @access public
* @param array Raw array
* @return array Cleaned array
*/
* Process returned data
*
* @access public
* @param array Raw array
* @return array Cleaned array
*/
public function apiProcessData( $raw=array() )
{
//-----------------------------------------
@@ -574,24 +570,24 @@ class classApiServer
}
/**
* Encode array
*
* @access private
* @param array Raw array
* @return string Encoded string
*/
* Encode array
*
* @access private
* @param array Raw array
* @return string Encoded string
*/
private function _encodeBase64Array( $array )
{
return base64_encode( serialize( $array ) );
}
/**
* Decode array
*
* @access private
* @param string Encoded string
* @return array Raw array
*/
* Decode array
*
* @access private
* @param string Encoded string
* @return array Raw array
*/
private function _decodeBase64Array( $data )
{
if ( ! is_array( $data ) )
@@ -609,5 +605,3 @@ class classApiServer
}
}
}
?>
+9 -6
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-07-07 21:22:30 -0400 (Tue, 07 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 291 $
* @version $Revision: 370 $
*
* Basic Usage Examples
* <code>
+9 -6
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-07-07 21:22:30 -0400 (Tue, 07 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 291 $
* @version $Revision: 370 $
*
* Basic Usage Examples
* <code>
+9 -6
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-07-07 21:22:30 -0400 (Tue, 07 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 291 $
* @version $Revision: 370 $
*
* Basic Usage Examples
* <code>
+20 -7
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-07-07 21:22:30 -0400 (Tue, 07 Jul 2009) $
* Last Updated: $Date: 2010-08-04 12:03:04 -0400 (Wed, 04 Aug 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 291 $
* @version $Revision: 444 $
*
* Basic Usage Examples
* <code>
@@ -105,6 +108,16 @@ class classCacheMemcache implements interfaceCache
memcache_add_server( $this->link, $server_info['memcache_server_3'], $server_info['memcache_port_3'] );
}
if( isset($server_info['memcache_server_4']) AND isset($server_info['memcache_port_4']) )
{
memcache_add_server( $this->link, $server_info['memcache_server_4'], $server_info['memcache_port_4'] );
}
if( isset($server_info['memcache_server_5']) AND isset($server_info['memcache_port_5']) )
{
memcache_add_server( $this->link, $server_info['memcache_server_5'], $server_info['memcache_port_5'] );
}
if( function_exists('memcache_set_compress_threshold') )
{
memcache_set_compress_threshold( $this->link, 20000, 0.2 );
@@ -179,6 +192,6 @@ class classCacheMemcache implements interfaceCache
*/
public function removeFromCache( $key )
{
return memcache_delete( $this->link, md5( $this->identifier . $key ) );
return memcache_delete( $this->link, md5( $this->identifier . $key ), 0 );
}
}
+125
View File
@@ -0,0 +1,125 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 370 $
*
* Basic Usage Examples
* <code>
* $cache = new cache_lib( 'identifier' );
* Update:
* $cache->putInCache( 'key', 'value' [, 'ttl'] );
* Remove
* $cache->removeFromCache( 'key' );
* Retrieve
* $cache->getFromCache( 'key' );
* </code>
*
*/
class classCacheWincache implements interfaceCache
{
/**
* Identifier
* @access private
* @var string
*/
private $identifier = '';
/**
* Constructor
*
* @access public
* @param string Unique identifier
* @return boolean Initiation successful
*/
public function __construct( $identifier='' )
{
if( !function_exists('wincache_ucache_get') )
{
$this->crashed = true;
return false;
}
$this->identifier = $identifier;
}
/**
* Put data into remote cache store
*
* @access public
* @param string Cache unique key
* @param string Cache value to add
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function putInCache( $key, $value, $ttl=0 )
{
$ttl = $ttl > 0 ? intval($ttl) : 0;
return wincache_ucache_set( md5( $this->identifier . $key ), $value, $ttl );
}
/**
* Retrieve a value from remote cache store
*
* @access public
* @param string Cache unique key
* @return mixed Cached value
*/
public function getFromCache( $key )
{
return wincache_ucache_get( md5( $this->identifier . $key ) );
}
/**
* Update value in remote cache store
*
* @access public
* @param string Cache unique key
* @param string Cache value to set
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function updateInCache( $key, $value, $ttl=0 )
{
$this->removeFromCache( $key );
return $this->putInCache( $key, $value, $ttl );
}
/**
* Remove a value in the remote cache store
*
* @access public
* @param string Cache unique key
* @return boolean Cache removal successful
*/
public function removeFromCache( $key )
{
return wincache_ucache_delete( md5( $this->identifier . $key ) );
}
/**
* Not used by this library
*
* @return boolean Disconnect successful
*/
public function disconnect()
{
return true;
}
}
+9 -6
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-07-07 21:22:30 -0400 (Tue, 07 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 291 $
* @version $Revision: 370 $
*
* Basic Usage Examples
* <code>
+9 -6
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* CAPTCHA abstraction - easily create, check and display CAPTHCA images
* Last Updated: $Date: 2009-02-05 15:14:40 -0500 (Thu, 05 Feb 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 224 $
* @version $Revision: 370 $
*/
class classCaptcha
@@ -13,9 +13,14 @@
* );
* </code>
* PLUG IN: Default GD image
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* @package Invision Power Services Kernel
* IP.Board v3.1.4
* Last Updated: $Date: 2010-09-13 17:11:29 -0400 (Mon, 13 Sep 2010) $
* </pre>
*
* @package IP.Board
* @subpackage Kernel
* @author Matt Mecham
* @copyright Invision Power Services, Inc.
* @version 1.0
@@ -425,6 +430,7 @@ class captchaPlugin
$strips = ceil( $image_x / $strip_count );
$im = imagecreatetruecolor( $image_x, $image_y );
$curr_offset = 0;
$alternate = 0;
for( $i = 0; $i < $strip_count; $i++ )
{
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -5,7 +5,7 @@
* - Documentation and latest version
* http://recaptcha.net/plugins/php/
* - Get a reCAPTCHA API Key
* http://recaptcha.net/api/getkey
* https://www.google.com/recaptcha/admin/create
* - Discussion group
* http://groups.google.com/group/recaptcha
*
@@ -37,76 +37,54 @@
/**
* The reCAPTCHA server URL's
*/
define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net");
define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net");
define("RECAPTCHA_VERIFY_SERVER", "api-verify.recaptcha.net");
define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
class captchaPlugin
{
/**
* Registry object
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
public $registry;
/**
* Database object
*
* @access protected
* @var object
*/
public $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
public $settings;
/**
* Request object
*
* @access protected
* @var object
*/
public $request;
/**
* Language object
*
* @access protected
* @var object
*/
public $lang;
/**
* Member object
*
* @access protected
* @var object
*/
public $member;
/**
* Member data object
*
* @access protected
* @var object
*/
public $memberData;
/**#@-*/
/**
* Error code from reCAPTCHA
*
* @access protected
* @var string
*/
public $error;
/**
* reCAPTCHA public key
*
* @var string
*/
public $public_key;
/**
* reCAPTCHA private key
*
* @var string
*/
public $private_key;
/**
* Flag whether to use SSL or not
*
* @var string
*/
public $useSSL;
/**
* Constructor
*
@@ -162,7 +140,7 @@ class captchaPlugin
};
</script>";
$html .= '<script type="text/javascript" src="'. $server . '/challenge?k=' . $this->public_key . '"></script>
$html .= '<script type="text/javascript" src="'. $server . '/challenge?k=' . $this->public_key . '"></script>
<noscript>
<iframe src="'. $server . '/noscript?k=' . $this->public_key . '" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
@@ -198,7 +176,7 @@ class captchaPlugin
return false;
}
$response = $this->_recaptchaPost( RECAPTCHA_VERIFY_SERVER, "/verify",
$response = $this->_recaptchaPost( RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
array (
'privatekey' => $this->private_key,
'remoteip' => $this->member->ip_address,
@@ -207,7 +185,7 @@ class captchaPlugin
)
);
$answers = explode( "\n", $response [1] );
$answers = explode( "\n", $response[1] );
if ( trim($answers[0]) == 'true' )
{
@@ -234,7 +212,7 @@ class captchaPlugin
*/
public function getSignupUrl( $domain = null, $appname = null )
{
return "http://recaptcha.net/api/getkey?" . $this->_encodeQueryString( array( 'domain' => $domain, 'app' => $appname ) );
return "https://www.google.com/recaptcha/admin/create?" . $this->_encodeQueryString( array( 'domain' => $domain, 'app' => $appname ) );
}
/**
+57 -58
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* HTTP Communications - send data via POST and read response
* Last Updated: $Date: 2009-02-04 15:05:02 -0500 (Wed, 04 Feb 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 6th January 2006 (12:24)
* @version $Revision: 222 $
* @version $Revision: 370 $
*
* Usage
* <code>
@@ -36,50 +39,48 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
class classCommunication
{
/**
* Use sockets flag
*
* @access public
* @var integer
*/
* Use sockets flag
*
* @access public
* @var integer
*/
public $use_sockets = 0;
/**
* Error array
*
* @access public
* @var array
*/
* Error array
*
* @access public
* @var array
*/
public $error = array();
/**
* Key prefix
* Prefix to identify communication strings
*
* @access public
* @var string
*/
* Key prefix
* Prefix to identify communication strings
*
* @access public
* @var string
*/
public $key_prefix = '__xsx__';
/**#@+
* Set Authentication
*
* @access public
* @var string
* @var string
* @var string
*/
* Set Authentication
*
* @access public
* @var string
*/
public $auth_req = 0;
public $auth_user;
public $auth_pass;
/**#@-*/
/**
* Receive data from the "send" function
*
* @access public
* @param array Array of fields to return
* @return array Array of fields
*/
* Receive data from the "send" function
*
* @access public
* @param array Array of fields to return
* @return array Array of fields
*/
public function communicationReceiveData( $return_fields=array() )
{
//-----------------------------------------
@@ -106,13 +107,13 @@ class classCommunication
}
/**
* Send the data
*
* @access public
* @param string URI to post to
* @param array Arry of post fields
* @return string File data
*/
* Send the data
*
* @access public
* @param string URI to post to
* @param array Arry of post fields
* @return string File data
*/
public function communicationSendData( $file_location='', $post_array=array() )
{
if ( ! is_array( $post_array ) OR ! count( $post_array ) )
@@ -129,12 +130,12 @@ class classCommunication
}
/**
* Filter out fields (optional)
*
* @access private
* @param array Array of fields to return
* @return array Array of fields
*/
* Filter out fields (optional)
*
* @access private
* @param array Array of fields to return
* @return array Array of fields
*/
private function _filterFields( $in_fields=array(), $out_fields=array() )
{
//-----------------------------------------
@@ -188,14 +189,14 @@ class classCommunication
}
/**
* Get file contents (with sockets)
*
* @access private
* @param string URI to post to
* @param array Arry of post fields
* @return string File data
* @todo [Future] Doesn't support "chunked" HTTP responses
*/
* Get file contents (with sockets)
*
* @access private
* @param string URI to post to
* @param array Arry of post fields
* @return string File data
* @todo [Future] Doesn't support "chunked" HTTP responses
*/
private function _postData( $file_location, $post_array )
{
//-------------------------------
@@ -344,5 +345,3 @@ class classCommunication
}
}
?>
+80 -79
View File
@@ -1,20 +1,23 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Character set conversion library
* Last Updated: $Date: 2009-09-25 07:10:57 -0400 (Fri, 25 Sep 2009) $
* Last Updated: $Date: 2010-05-07 19:47:45 -0400 (Fri, 07 May 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @author Mikolaj Jedrzejak <mikolajj@op.pl>
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @copyright Copyright Mikolaj Jedrzejak (c) 2003-2004
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 2nd December 2005 10:18
* @version $Revision: 328 $
* @version $Revision: 404 $
* @version 1.0 2004-07-27 00:37
* @link http://www.unicode.org Unicode Homepage
* @link http://www.mikkom.pl My Homepage
@@ -46,47 +49,47 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
class classConvertCharset
{
/**
* Array of error messages associated with the conversion
*
* @access public
* @var array Error messages
*/
* Array of error messages associated with the conversion
*
* @access public
* @var array Error messages
*/
public $errors = array();
/**
* Should characters be turned into numeric entities
*
* @access private
* @var boolean
*/
* Should characters be turned into numeric entities
*
* @access private
* @var boolean
*/
private $entities = false;
/**
* Conversion method to use.
* Valid values include: mb, iconv, recode, internal
*
* @access public
* @var string
*/
* Conversion method to use.
* Valid values include: mb, iconv, recode, internal
*
* @access public
* @var string
*/
public $method = 'internal';
/**
* Path for character sets
*
* @access public
* @var string
*/
* Path for character sets
*
* @access public
* @var string
*/
public $charsetPath = '';
/**
* Converts a text string from its current charset to a destination charset
*
* @access public
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
* Converts a text string from its current charset to a destination charset
*
* @access public
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
public function convertEncoding( $string, $string_char_set, $destination_char_set='UTF-8' )
{
$string_char_set = strtolower($string_char_set);
@@ -133,14 +136,14 @@ class classConvertCharset
}
/**
* Converts a text string from its current charset to a destination charset using mb_convert_encoding
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
* Converts a text string from its current charset to a destination charset using mb_convert_encoding
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_mb( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'mb_convert_encoding' ) )
@@ -165,14 +168,14 @@ class classConvertCharset
}
/**
* Converts a text string from its current charset to a destination charset using iconv
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
* Converts a text string from its current charset to a destination charset using iconv
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_iconv( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'iconv' ) )
@@ -188,14 +191,14 @@ class classConvertCharset
}
/**
* Converts a text string from its current charset to a destination charset using recode_string
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
* Converts a text string from its current charset to a destination charset using recode_string
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_recode( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'recode_string' ) )
@@ -211,15 +214,15 @@ class classConvertCharset
}
/**
* Converts a text string from its current charset to a destination charset using internal conversion class.
* The bulk of this function was written by Mikolaj Jedrzejak and used with permission via the License
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
* Converts a text string from its current charset to a destination charset using internal conversion class.
* The bulk of this function was written by Mikolaj Jedrzejak and used with permission via the License
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_internal( $string, $string_char_set, $destination_char_set='UTF-8' )
{
$text = '';
@@ -235,15 +238,15 @@ class classConvertCharset
* "entities" enabled, because we need to use proper destination(to)/source(from)
* encoding table to write proper entities.
*
* This is the first case. We are convertinf from 1byte chars...
* This is the first case. We are converting from 1byte chars...
**/
if ($string_char_set != "utf-8")
{
{
/**
* Now build table with both charsets for encoding change.
**/
if ($destination_char_set != "utf-8")
{
{
$charsetTable = $this->_makeConversionTable( $string_char_set, $destination_char_set );
}
else
@@ -390,9 +393,9 @@ class classConvertCharset
*
* @access private
* @param string $unicodeString Input Unicode string (1 char can take more than 1 byte)
* @return string This is an input string olso with unicode chars, bus saved as entities
* @return string This is an input string also with unicode chars, but saved as entities
* @see _hexToUtf()
**/
*/
private function _unicodeEntity( $unicodeString )
{
$outString = "";
@@ -469,7 +472,7 @@ class classConvertCharset
* @param string $utfCharInHex Hexadecimal value of a unicode char.
* @return string Encoded hexadecimal value as a regular char.
* @see _unicodeEntity()
**/
*/
private function _hexToUtf( $utfCharInHex )
{
$outputChar = "";
@@ -531,7 +534,7 @@ class classConvertCharset
* @param string $firstEncoding Name of first encoding and first encoding filename (thay have to be the same)
* @param string $secondEncoding Name of second encoding and second encoding filename (thay have to be the same). Optional for building a joined table.
* @return array Table necessary to change one encoding to another.
**/
*/
private function _makeConversionTable( $firstEncoding, $secondEncoding = "" )
{
$convertTable = array();
@@ -593,6 +596,4 @@ class classConvertCharset
return $convertTable;
}
}
?>
}
File diff suppressed because it is too large. Load diff
+231 -52
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Database Abstraction Layer
* Last Updated: $Date: 2009-12-07 21:58:39 -0500 (Mon, 07 Dec 2009) $
* Last Updated: $Date: 2010-09-20 20:20:12 -0400 (Mon, 20 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 351 $
* @version $Revision: 467 $
*
* Basic Usage Examples
* <code>
@@ -265,6 +268,16 @@ interface interfaceDb
*/
public function checkBooleanFulltextSupport();
/**
* Test to see whether an index exists in a table
*
* @access public
* @param string Index name
* @param string Table name
* @return boolean Field exists or not
*/
public function checkForIndex( $index, $table );
/**
* Test to see whether a field exists in a table
*
@@ -308,7 +321,7 @@ interface interfaceDb
* @param string [Optional] Default value
* @return resource Query id
*/
public function addField( $table, $field, $type, $default='' );
public function addField( $table, $field, $type, $default=NULL );
/**
* Add index to database column
@@ -319,6 +332,7 @@ interface interfaceDb
* @param string Fieldlist col1, col2
* @param bool Is primary key?
* @return resource Query id
* @todo [Future] Add support for fulltext indexes (right now can only do generic index or primary key)
*/
public function addIndex( $table, $name, $fieldlist, $isPrimary=false );
@@ -366,6 +380,14 @@ interface interfaceDb
*/
public function getTableNames();
/**
* Get array of field names in table
*
* @param string Table name
* @return array SQL tables
*/
public function getFieldNames( $table );
/**
* Determine if table already has a fulltext index
*
@@ -592,7 +614,14 @@ interface interfaceDb
*/
public function buildDateFormat( $column, $format );
/**
/**
* Build rand() string
*
* @return string SQL-formatted random order string
*/
public function buildRandomOrder();
/**
* Build fulltext search string
*
* @param string Column to search against
@@ -611,7 +640,18 @@ interface interfaceDb
* @return mixed Output to screen, or return void
*/
public function throwFatalError( $the_error='' );
/**
* Returns a portion of a WHERE query suitable for use.
* Specific to tables with a field that has a comma separated list of IDs.
*
* @param array Array of perm IDs
* @param string DB field to search in
* @param boolean check for '*' in the field to denote 'global'
* @return mixed Output to screen, or return void
*/
public function buildWherePermission( array $ids, $field='', $incStarCheck=true );
/**
* Logs SQL error message to log file
*
@@ -863,6 +903,15 @@ abstract class dbMain
* @var string
*/
public $fieldEncapsulate = "'";
/**
* Field name encapsulation character
* @see http://community.invisionpower.com/tracker/issue-20621-postgresql-driver-field-names-not-properly-escaped/
*
* @access public
* @var string
*/
public $fieldNameEncapsulate = '';
/**
* db_driver constructor
@@ -902,6 +951,18 @@ abstract class dbMain
return $this->cur_query;
}
/**
* Turns table identity insert on/off
*
* @access public
* @param string Table name
* @param string On or Off
* @return string
*/
public function setTableIdentityInsert( $tableName, $status='OFF' )
{
}
/**
* Takes array of set commands and generates a SQL formatted query
*
@@ -1107,6 +1168,19 @@ abstract class dbMain
}
}
/**
* Test to see whether an index exists in a table
*
* @access public
* @param string Index name
* @param string Table name
* @return boolean Field exists or not
*/
public function checkForIndex( $index, $table )
{
return false;
}
/**
* Test to see whether a field exists in a table
*
@@ -1255,6 +1329,28 @@ abstract class dbMain
return $this->_triedToLoadCacheFiles[ $classname ];
}
/**
* Returns a portion of a WHERE query suitable for use.
* Specific to tables with a field that has a comma separated list of IDs.
*
* @param array Array of perm IDs
* @param string DB field to search in
* @param boolean check for '*' in the field to denote 'global'
* @return mixed Output to screen, or return void
*/
public function buildWherePermission( array $ids, $field='', $incStarCheck=true )
{
/* Just use a LIKE chain for items without a specific implementation */
$where = '(' . $this->buildLikeChain( $field, $ids ) . ')';
if ( $incStarCheck === true )
{
$where = ' OR ( ' . $field . '=\'*\' )';
}
return $where;
}
/**
* Load Query cache file
*
@@ -1316,7 +1412,7 @@ abstract class dbMain
$v = $this->addSlashes( $v );
}
$field_names .= "$k,";
$field_names .= $this->fieldNameEncapsulate . "$k" . $this->fieldNameEncapsulate . ',';
//-----------------------------------------
// Forcing data type?
@@ -1348,7 +1444,7 @@ abstract class dbMain
else
{
if ( is_numeric( $v ) and intval($v) == $v )
if ( is_numeric( $v ) and strcmp( intval($v), $v ) === 0 )
{
$field_values .= $v.",";
}
@@ -1442,7 +1538,7 @@ abstract class dbMain
else
{
if ( is_numeric( $v ) and intval($v) == $v )
if ( is_numeric( $v ) and strcmp( intval($v), $v ) === 0 )
{
$return_string .= $k . "=" . $v . ",";
}
@@ -1532,7 +1628,7 @@ abstract class dbMain
/**
* Generates calc rows in the query if supported / runs count(*) if not
*
* @return boolean
* @access protected
* @return void Sets $this->_calcRows
*/
abstract protected function _buildCalcRows();
@@ -1552,7 +1648,94 @@ abstract class dbMain
$this->error = $this->_getErrorString();
$this->error_no = $this->_getErrorNumber();
$errTemplate = 'ipsDriverError';
$nonIPSErrors = array( '1012-1021', '1023-1027', '1030-1031', '1034-1043', '1129-1131', '1150-1153', 1194, 1195, '1203-1207' );
/* MySQL: Is this non IPS error? */
if ( $this->usingClass == 'db_driver_mysql' )
{
if ( stristr( $this->error, 'has gone away') OR stristr( $this->error, 'connect to local mysql server through socket') )
{
$errTemplate = 'ipsServerError';
}
else if ( $this->error_no )
{
foreach( $nonIPSErrors as $id )
{
if ( strstr( $id, '-' ) )
{
list( $a, $b ) = explode( '-', $id );
if ( $a AND $b )
{
if ( $this->error_no >= $a AND $this->error_no <= $b )
{
$errTemplate = 'ipsServerError';
}
}
}
else if ( $this->error_no == intval( $id ) )
{
$errTemplate = 'ipsServerError';
}
}
}
}
/* Fetch debug information */
$_debug = debug_backtrace();
$_dString = '';
if ( is_array( $_debug ) and count( $_debug ) )
{
foreach( $_debug as $idx => $data )
{
/* Remove non-essential items */
if ( $data['class'] == 'dbMain' OR $data['class'] == 'ips_DBRegistry' OR $data['class'] == 'ipsRegistry' OR $data['class'] == 'ipsController' OR $data['class'] == 'ipsCommand' OR $data['class'] == 'db_driver_mysql' )
{
continue;
}
$_dbString[ $idx ] = array( 'file' => $data['file'],
'line' => $data['line'],
'function' => $data['function'],
'class' => $data['class'] );
}
}
$_error_string = "\n ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
$_error_string .= "\n Date: ". date( 'r' );
$_error_string .= "\n Error: " . $this->error_no . ' - ' . $this->error;
$_error_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'] . ' - ' . $_SERVER['REQUEST_URI'];
$_error_string .= "\n ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
$_error_string .= "\n " . $the_error;
$_error_string .= "\n .--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.";
if ( count( $_dbString ) )
{
$_error_string .= "\n | File | Function | Line No. |";
$_error_string .= "\n |----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------|";
foreach( $_dbString as $i => $data )
{
if ( defined('DOC_IPS_ROOT_PATH') )
{
$data['file'] = str_replace( DOC_IPS_ROOT_PATH, '', $data['file'] );
}
/* Reset */
$data['func'] = "[" . $data['class'] . '].' . $data['function'];
/* Pad right */
$data['file'] = str_pad( $data['file'], 75 );
$data['func'] = str_pad( $data['func'], 78 );
$data['line'] = str_pad( $data['line'], 18 );
$_error_string .= "\n | " . $data['file'] . "| " . $data['func'] . '| ' . $data['line'] . '|';
$_error_string .= "\n '----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'";
}
}
if ( $this->return_die == true )
{
$this->error = ( $this->error == "" ? $the_error : $this->error );
@@ -1561,46 +1744,32 @@ abstract class dbMain
}
else if ( $this->obj['use_error_log'] AND $this->obj['error_log'] )
{
$_debug = debug_backtrace(FALSE);
$_dString = '';
if ( is_array( $_debug ) and count( $_debug ) )
{
foreach( $_debug as $idx => $data )
{
/* Remove non-essential items */
if ( $data['class'] == 'dbMain' OR $data['class'] == 'ips_DBRegistry' OR $data['class'] == 'ipsRegistry' OR $data['class'] == 'ipsController' OR $data['class'] == 'ipsCommand' )
{
continue;
}
$_dbString[ $idx ] = array( 'file' => $data['file'],
'line' => $data['line'],
'function' => $data['function'],
'class' => $data['class'] );
}
}
$_error_string = "\n===================================================";
$_error_string .= "\n Дата: ". date( 'r' );
$_error_string .= "\n Номер ошибки: " . $this->error_no;
$_error_string .= "\n Ошибка: " . $this->error;
$_error_string .= "\n IP Адрес: " . $_SERVER['REMOTE_ADDR'];
$_error_string .= "\n Страница: " . $_SERVER['REQUEST_URI'];
$_error_string .= "\n Отладочная информация: " . var_export( $_dbString, TRUE );
$_error_string .= "\n ".$the_error;
if ( $FH = @fopen( $this->obj['error_log'], 'a' ) )
{
@fwrite( $FH, $_error_string );
@fclose( $FH );
}
/* Write to latest log also */
if ( is_dir( DOC_IPS_ROOT_PATH . 'cache' ) )
{
@file_put_contents( DOC_IPS_ROOT_PATH . 'cache/sql_error_latest.cgi', trim( $_error_string ) );
}
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
{
@header( "HTTP/1.0 503 Service Unavailable" );
}
else
{
@header( "HTTP/1.1 503 Service Unavailable" );
}
if( $this->use_template )
{
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/ipsDriverError.php' );
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/'. $errTemplate . '.php' );
$template = new ipsDriverErrorTemplate();
print $template->showError();
print $template->showError( $errTemplate == 'ipsServerError' ? true : false, $the_error );
}
else
{
@@ -1615,11 +1784,21 @@ abstract class dbMain
{
$the_error .= "\n\nSQL error: ".$this->error."\n";
$the_error .= "SQL error code: ".$this->error_no."\n";
$the_error .= "Date: ".date("l dS \o\f F Y h:i:s A");
$the_error .= "Date: ".date("l dS F Y h:i:s A");
$the_error .= "\n\n" . $_error_string;
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
{
@header( "HTTP/1.0 503 Service Unavailable" );
}
else
{
@header( "HTTP/1.1 503 Service Unavailable" );
}
if( $this->use_template )
{
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/ipsDriverError.php' );
require_once( DOC_IPS_ROOT_PATH . 'cache/skin_cache/'. $errTemplate . '.php' );
$template = new ipsDriverErrorTemplate();
print $template->showError( true, $the_error );
}
@@ -1665,14 +1844,14 @@ abstract class dbMain
if ( $query == '{start}' AND ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) )
{
$_string = "\n\n\n\n\n==============================================================================";
$_string .= "\n========================= НАЧАЛО ===================================";
$_string .= "\n========================= START ===================================";
$_string .= "\n========================= " . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . " ===================================";
$_string .= "\n==============================================================================";
}
else if ( $query == '{end}' AND ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) )
{
$_string = "\n==============================================================================";
$_string .= "\n========================= КОНЕЦ ===================================";
$_string .= "\n========================= END ===================================";
$_string .= "\n========================= " . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . " ===================================";
$_string .= "\n==============================================================================";
}
@@ -1680,9 +1859,9 @@ abstract class dbMain
{
$_string = "\n==============================================================================";
$_string .= "\n URL: ". $_SERVER['PHP_SELF'] . $_SERVER['REQUEST_URI'];
$_string .= "\n Дата: ". date( 'r' );
$_string .= "\n IP адрес: " . $_SERVER['REMOTE_ADDR'];
$_string .= "\n Затраченное время: ".$endtime;
$_string .= "\n Date: ". date( 'r' );
$_string .= "\n IP Address: " . $_SERVER['REMOTE_ADDR'];
$_string .= "\n Time Taken: ".$endtime;
$_string .= "\n ".$query;
$_string .= "\n".$data;
$_string .= "\n==============================================================================";
+189 -49
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* MySQL Database Driver :: Further loads mysql or mysqli client appropriately
* Last Updated: $Date: 2009-10-01 14:35:04 -0400 (Thu, 01 Oct 2009) $
* Last Updated: $Date: 2010-10-06 12:04:54 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 335 $
* @version $Revision: 473 $
*/
/**
@@ -29,14 +32,6 @@ if ( ! class_exists( 'dbMain' ) )
require_once( dirname( __FILE__ ) . '/classDb.php' );
}
/**
* Allow < 4.3.0 PHP client access
*/
if ( ! defined('IPS_MAIN_DB_CLASS_LEGACY') )
{
define('IPS_MAIN_DB_CLASS_LEGACY', ( PHP_VERSION < '4.3.0' ) ? TRUE : FALSE );
}
abstract class db_main_mysql extends dbMain
{
/**
@@ -54,6 +49,15 @@ abstract class db_main_mysql extends dbMain
* @var array Table names cached
*/
protected $cached_tables = array();
/**
* Field name encapsulation character
* @see http://community.invisionpower.com/tracker/issue-20621-postgresql-driver-field-names-not-properly-escaped/
*
* @access public
* @var string
*/
public $fieldNameEncapsulate = '`';
/**
* Delete data from a table
@@ -81,16 +85,16 @@ abstract class db_main_mysql extends dbMain
{
$this->_buildOrderBy( $orderBy );
}
if ( $where AND $limit AND is_array( $limit ) )
{
$this->_buildLimit( $limit[0], $limit[1] );
}
$result = $this->_determineShutdownAndRun( $this->cur_query, $shutdown );
$this->cur_query = '';
return $result;
}
@@ -171,19 +175,19 @@ abstract class db_main_mysql extends dbMain
{
//$dbb = $this->compileUpdateString( $set );
$dbb = array();
foreach( $set as $k => $v )
{
$dbb[] = "{$k}=VALUES({$k})";
}
$dbb = implode( ',', $dbb );
$query = "INSERT INTO " . $this->obj['sql_tbl_prefix'] . $table . " ({$dba['FIELD_NAMES']}) VALUES({$dba['FIELD_VALUES']}) ON DUPLICATE KEY UPDATE " . $dbb;
}
IPSDebug::addLogMessage( $query, 'replaceintolog' );
return $this->_determineShutdownAndRun( $query, $shutdown );
}
@@ -257,6 +261,41 @@ abstract class db_main_mysql extends dbMain
return FALSE;
}
}
/**
* Test to see whether an index exists in a table
*
* @access public
* @param string Index name
* @param string Table name
* @return boolean Field exists or not
*/
public function checkForIndex( $index, $table )
{
$current = $this->return_die;
$this->return_die = true;
$this->error = "";
$return = false;
$indexes = array();
$q = $this->query( "SHOW INDEX FROM " . $this->obj['sql_tbl_prefix'] . $table );
if ( $q AND $this->getTotalRows($q) )
{
while( $check = $this->fetch($q) )
{
$indexes[ $check['Key_name'] ] = $check['Key_name'];
}
}
$this->error = "";
$this->return_die = $current;
$this->error_no = 0;
$this->failed = false;
return ( in_array( $index, $indexes ) ) ? true : false;
}
/**
* Test to see whether a field exists in a table
@@ -366,13 +405,13 @@ abstract class db_main_mysql extends dbMain
* @param string [Optional] Default value
* @return resource Query id
*/
public function addField( $table, $field, $type, $default='' )
public function addField( $table, $field, $type, $default=NULL )
{
$default = $default ? "DEFAULT {$default}" : 'NULL';
$default = $default != NULL ? "DEFAULT {$default}" : 'NULL';
return $this->query( "ALTER TABLE " . $this->obj['sql_tbl_prefix'] . $table . " ADD {$field} {$type} {$default}" );
}
/**
* Add index to database column
*
@@ -386,7 +425,7 @@ abstract class db_main_mysql extends dbMain
public function addIndex( $table, $name, $fieldlist, $isPrimary=false )
{
$fieldlist = ( $fieldlist ) ? $fieldlist : $name;
if ( $isPrimary )
{
return $this->query( "ALTER TABLE " . $this->obj['sql_tbl_prefix'] . $table . " ADD PRIMARY KEY ( " . $fieldlist . ' )' );
@@ -465,6 +504,47 @@ abstract class db_main_mysql extends dbMain
return array();
}
}
/**
* Get array of field names in table
*
* @param string Table name
* @return array SQL tables
*/
public function getFieldNames( $table )
{
//-----------------------------------------
// Inline field name caching
//-----------------------------------------
static $_fields = array();
if( count($_fields[ $table ]) )
{
return $_fields[ $table ];
}
$current = $this->return_die;
$this->return_die = true;
$qid = $this->query( "SHOW FIELDS FROM " . $this->obj['sql_tbl_prefix'] . $table );
$this->return_die = $current;
if( $qid )
{
while( $r = $this->fetch($qid) )
{
$_fields[ $table ][] = $r['Field'];
}
return $_fields[ $table ];
}
else
{
return array();
}
}
/**
* Determine if table already has a fulltext index
@@ -600,7 +680,7 @@ abstract class db_main_mysql extends dbMain
return $return_string;
}
/**
* Build CAST string
*
@@ -609,6 +689,12 @@ abstract class db_main_mysql extends dbMain
*/
public function buildCast( $data, $columnType )
{
/* mySQL does not support casting as VARCHAR, but it isn't needed either */
if( $columnType == 'VARCHAR' )
{
return $data;
}
return "CAST( {$data} AS {$columnType} )";
}
@@ -636,7 +722,7 @@ abstract class db_main_mysql extends dbMain
*/
public function buildRegexp( $column, $data )
{
return "{$column} REGEXP '," . implode( ',|,', $data ) . ",|\\\*'";
return "{$column} REGEXP '," . implode( ',|,', $data ) . ',|\\\*\'';
}
/**
@@ -661,7 +747,44 @@ abstract class db_main_mysql extends dbMain
return $return;
}
/**
* Returns a portion of a WHERE query suitable for use.
* Specific to tables with a field that has a comma separated list of IDs.
*
* @param array Array of perm IDs
* @param string DB field to search in
* @param boolean check for '*' in the field to denote 'global'
* @return mixed Output to screen, or return void
*/
public function buildWherePermission( array $ids, $field='', $incStarCheck=true )
{
/* Just use a LIKE chain for items without a specific implementation */
$where = '( ';
$_or = array();
foreach( $ids as $i )
{
$_or[] = "FIND_IN_SET(" . $i . "," . $field . ")";
}
if ( count( $_or ) )
{
$where .= '( ' . implode( " OR ", $_or ) . ' )';
}
else
{
$where .= "1 = 1";
}
if ( $incStarCheck === true )
{
$where .= ' OR ( ' . $field . '=\'*\' )';
}
return $where . ' )';
}
/**
* Build instr string
*
@@ -733,7 +856,7 @@ abstract class db_main_mysql extends dbMain
{
return "LENGTH(" . $column . ")";
}
/**
* Build lower string
*
@@ -816,6 +939,17 @@ abstract class db_main_mysql extends dbMain
{
return "DATE_FORMAT(" . $column . ", '{$format}')";
}
/**
* Build rand() string
*
* @access public
* @return string SQL-formatted random order string
*/
public function buildRandomOrder()
{
return "RAND()";
}
/**
* Build fulltext search string
@@ -882,19 +1016,19 @@ abstract class db_main_mysql extends dbMain
if( is_array( $table ) )
{
$_tables = array();
foreach( $table as $tbl => $alias )
{
$_tables[] = $this->obj['sql_tbl_prefix'] . $tbl . ' ' . $alias;
}
$table = implode( ', ', $_tables );
}
else
{
$table = $this->obj['sql_tbl_prefix'] . $table;
}
$this->cur_query .= "SELECT {$_calcRows}{$get} FROM " . $table;
if ( $where != "" )
@@ -915,9 +1049,10 @@ abstract class db_main_mysql extends dbMain
$joinleft_array = array();
$where_array = array();
$final_from = array();
$select_array[] = $get;
$from_array[] = $table;
$hasLeft = false;
$hasInner = false;
if ( $where )
{
@@ -938,18 +1073,9 @@ abstract class db_main_mysql extends dbMain
$select_array[] = $join['select'];
}
if ( $join['type'] == 'inner' )
{
# Join is inline
$from_array[] = $join['from'];
if ( $join['where'] )
{
$where_array[] = $join['where'];
}
}
else if ( $join['type'] == 'left' OR !$join['type'] )
if ( !isset($join['type']) OR !$join['type'] OR $join['type'] == 'left' )
{
$hasLeft = true;
# Join is left or not specified (assume left)
$tmp = " LEFT JOIN ";
@@ -967,6 +1093,18 @@ abstract class db_main_mysql extends dbMain
unset( $tmp );
}
else if ( $join['type'] == 'inner' )
{
$hasInner = true;
# Join is inline
$from_array[] = $join['from'];
if ( $join['where'] )
{
$where_array[] = $join['where'];
}
}
else
{
# Not using any other type of join
@@ -986,10 +1124,12 @@ abstract class db_main_mysql extends dbMain
}
}
$get = implode( "," , $select_array );
$table = implode( "," , $final_from );
$where = implode( " AND " , $where_array );
$join = implode( "\n" , $joinleft_array );
$get = implode( "," , $select_array );
#http://bugs.mysql.com/bug.php?id=37925
$table = ( $hasLeft === true && $hasInner === true ) ? '(' . implode( ",", $final_from ) . ')' : implode( ",", $final_from );
$where = implode( " AND " , $where_array );
$join = implode( "\n" , $joinleft_array );
$this->cur_query .= "SELECT {$_calcRows}{$get} FROM {$table}";
+79 -86
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* MySQL Database Driver :: MySQL client
* Last Updated: $Date: 2009-09-15 08:34:24 -0400 (Tue, 15 Sep 2009) $
* Last Updated: $Date: 2010-07-13 19:56:26 -0400 (Tue, 13 Jul 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 327 $
* @version $Revision: 438 $
*/
class db_driver_mysql extends db_main_mysql implements interfaceDb
@@ -29,11 +32,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
define( 'MYSQLI_USED', 1 );
}
//--------------------------------------
// Set up any required connect vars here
//--------------------------------------
$this->connect_vars['mysql_tbl_type'] = "";
}
@@ -48,20 +51,20 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Done SQL prefix yet?
//-----------------------------------------
$this->_setPrefix();
//-----------------------------------------
// Load query file
//-----------------------------------------
$this->_loadCacheFile();
//-----------------------------------------
// Connect
//-----------------------------------------
if ( $this->obj['persistent'] AND ! IPS_MAIN_DB_CLASS_LEGACY )
if ( $this->obj['persistent'] )
{
$this->connection_id = @mysql_pconnect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
@@ -70,22 +73,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
);
}
else
{
if ( IPS_MAIN_DB_CLASS_LEGACY )
{
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass']
);
}
else
{
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass'] ,
$this->obj['force_new_connection']
);
}
{
$this->connection_id = @mysql_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass'] ,
$this->obj['force_new_connection']
);
}
if ( ! $this->connection_id )
@@ -155,12 +148,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Change the table prefix if needed
//-----------------------------------------
if ( $this->no_prefix_convert )
{
$bypass = 1;
}
if ( ! $bypass )
{
if ( $this->obj['sql_tbl_prefix'] != "ibf_" and ! $this->prefix_changed )
@@ -210,11 +203,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
#I had to switch this around... The query goes first, connection id second. Otherwise it just breaks - KF
#$this->query_id = mysql_query($this->connection_id, $the_query );
$this->query_id = mysql_query( $the_query, $this->connection_id );
@@ -222,7 +215,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->force_data_type = array();
$this->allow_sub_select = false;
@@ -230,25 +223,25 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$this->throwFatalError("mySQL query error: $the_query");
}
//-----------------------------------------
// Debug?
//-----------------------------------------
if ( ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) OR ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) OR ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) )
{
$endtime = IPSDebug::endTimer();
$_data = '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysql_query("EXPLAIN {$the_query}", $this->connection_id);
$_bad = false;
while( $array = mysql_fetch_array($eid) )
{
$array['extra'] = isset( $array['extra'] ) ? $array['extra'] : '';
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: ". $array['table'];
$_data .= "\n|Type: ". $array['type'];
@@ -259,18 +252,18 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$_data .= "\n|Rows: ". $array['rows'];
$_data .= "\n|Extra: ". $array['Extra'];
//$_data .= "\n+------------------------------------------------------------------------------+";
if ( ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) AND stristr( $array['Extra'], 'filesort' ) OR stristr( $array['Extra'], 'temporary' ) )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['bad_log'], TRUE );
}
if ( ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) AND $endtime >= $this->obj['use_slow_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['slow_log'], TRUE );
}
}
if ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime );
@@ -284,21 +277,21 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Debugging?
//-----------------------------------------
if ($this->obj['debug'])
{
$endtime = IPSDebug::endTimer();
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysql_query( "EXPLAIN {$the_query}", $this->connection_id );
$this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>
<tr>
<td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>
@@ -314,7 +307,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
while( $array = mysql_fetch_array($eid) )
{
$type_col = '#FFFFFF';
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const')
{
$type_col = '#D8FFD4';
@@ -323,7 +316,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$type_col = '#FFEEBA';
}
$this->debug_html .= "<tr bgcolor='#FFFFFF'>
<td>$array[table]&nbsp;</td>
<td bgcolor='$type_col'>$array[type]&nbsp;</td>
@@ -335,14 +328,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
<td>$array[Extra]&nbsp;</td>
</tr>\n";
}
$this->sql_time += $endtime;
if ($endtime > 0.1)
{
$endtime = "<span style='color:red'><b>$endtime</b></span>";
}
$this->debug_html .= "<tr>
<td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>MySQL time</b>: $endtime</b></td>
</tr>
@@ -363,11 +356,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
</table><br />\n\n";
}
}
$this->query_count++;
$this->obj['cached_queries'][] = $the_query;
return $this->query_id;
}
@@ -381,7 +374,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysql_affected_rows( $this->connection_id );
}
/**
* Retrieve number of rows in result set
*
@@ -398,7 +391,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return mysql_num_rows( $query_id );
}
/**
* Retrieve latest autoincrement insert id
*
@@ -409,7 +402,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysql_insert_id($this->connection_id);
}
/**
* Retrieve the current thread id
*
@@ -420,7 +413,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysql_thread_id($this->connection_id);
}
/**
* Free result set from memory
*
@@ -434,10 +427,10 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$query_id = $this->query_id;
}
@mysql_free_result( $query_id );
}
/**
* Retrieve row from database
*
@@ -451,9 +444,9 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$query_id = $this->query_id;
}
$this->record_row = mysql_fetch_array( $query_id, MYSQL_ASSOC );
return $this->record_row;
}
@@ -467,12 +460,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function fetchCalculatedRows( $alias='count' )
{
$calcRowsHandle = mysql_query( "SELECT FOUND_ROWS() as " . $alias, $this->connection_id );
$val = mysql_fetch_array( $calcRowsHandle, MYSQL_ASSOC );
return intval( $val[ $alias ] );
}
/**
* Get array of fields in result set
*
@@ -483,17 +476,17 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function getResultFields( $query_id=null )
{
$fields = array();
if ( !$query_id )
{
$query_id = $this->query_id;
}
while( $field = mysql_fetch_field($query_id) )
{
$fields[] = $field;
}
return $fields;
}
@@ -509,14 +502,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return $this->cached_tables;
}
$current = $this->return_die;
$this->return_die = true;
$qid = $this->query( "SHOW TABLES FROM `{$this->obj['sql_database']}`" );
$this->return_die = $current;
if( $qid AND $this->getTotalRows($qid) )
{
while( $result = mysql_fetch_array($qid) )
@@ -524,12 +517,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$this->cached_tables[] = $result[0];
}
}
mysql_free_result($qid);
return $this->cached_tables;
}
/**
* Retrieve SQL server version
*
@@ -541,19 +534,19 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
if ( ! $this->sql_version and ! $this->true_version )
{
$this->query( "SELECT VERSION() AS version" );
if ( ! $row = $this->fetch() )
{
$this->query( "SHOW VARIABLES LIKE 'version' ");
$row = $this->fetch();
}
$this->true_version = $row['version'];
$tmp = explode( '.', preg_replace( "#[^\d\.]#", "\\1", $row['version'] ) );
$this->sql_version = sprintf('%d%02d%02d', $tmp[0], $tmp[1], $tmp[2] );
}
return $this->sql_version;
}
@@ -566,7 +559,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
*/
public function addSlashes( $t )
{
return ( IPS_MAIN_DB_CLASS_LEGACY ) ? mysql_escape_string($t) : mysql_real_escape_string($t, $this->connection_id );
return @mysql_real_escape_string( $t, $this->connection_id );
}
/**
@@ -586,7 +579,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return @mysql_errno();
}
}
/**
* Get SQL error message
*
@@ -604,6 +597,6 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return @mysql_error();
}
}
} // end class
+86 -80
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* MySQL Database Driver :: MySQLi client
* Last Updated: $Date: 2009-09-15 08:34:24 -0400 (Tue, 15 Sep 2009) $
* Last Updated: $Date: 2010-10-06 12:04:54 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 28th February 2005 16:46
* @version $Revision: 327 $
* @version $Revision: 473 $
*/
class db_driver_mysql extends db_main_mysql implements interfaceDb
@@ -24,7 +27,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
* @var boolean Connection failed
*/
private $connect_failed = false;
/**
* constructor
*
@@ -37,11 +40,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
define( 'MYSQLI_USED', 1 );
}
//--------------------------------------
// Set up any required connect vars here
//--------------------------------------
$this->connect_vars['mysql_tbl_type'] = "";
}
@@ -56,28 +59,28 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Done SQL prefix yet?
//-----------------------------------------
$this->_setPrefix();
//-----------------------------------------
// Load query file
//-----------------------------------------
$this->_loadCacheFile();
//-----------------------------------------
// Connect
//-----------------------------------------
/* Did we add a port inline? */
if ( ! $this->obj['sql_port'] AND strstr( $this->obj['sql_host'], ':' ) )
{
list( $host, $port ) = explode( ':', $this->obj['sql_host'] );
$this->obj['sql_host'] = $host;
$this->obj['sql_port'] = intval( $port );
}
if( $this->obj['sql_port'] )
{
$this->connection_id = @mysqli_connect( $this->obj['sql_host'] ,
@@ -95,28 +98,29 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$this->obj['sql_database']
);
}
if ( ! $this->connection_id )
{
$this->usingClass = 'db_driver_mysql';
$this->connect_failed = true;
$this->throwFatalError();
return FALSE;
}
mysqli_autocommit( $this->connection_id, TRUE );
//-----------------------------------------
// Remove sensitive data
//-----------------------------------------
unset( $this->obj['sql_host'] );
unset( $this->obj['sql_user'] );
unset( $this->obj['sql_pass'] );
//-----------------------------------------
// If there's a charset set, run it
//-----------------------------------------
if( $this->obj['sql_charset'] )
{
$this->query( "SET NAMES '{$this->obj['sql_charset']}'" );
@@ -134,7 +138,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return TRUE;
}
/**
* Close database connection
*
@@ -148,7 +152,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return @mysqli_close( $this->connection_id );
}
}
/**
* Execute a direct database query
*
@@ -162,12 +166,12 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Change the table prefix if needed
//-----------------------------------------
if ( $this->no_prefix_convert )
{
$bypass = 1;
}
if ( ! $bypass )
{
if ( $this->obj['sql_tbl_prefix'] != "ibf_" and ! $this->prefix_changed )
@@ -218,7 +222,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Run the query
//-----------------------------------------
@@ -228,7 +232,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
//-----------------------------------------
// Reset array...
//-----------------------------------------
$this->force_data_type = array();
$this->allow_sub_select = false;
@@ -236,25 +240,25 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$this->throwFatalError("mySQL query error: $the_query");
}
//-----------------------------------------
// Logging?
//-----------------------------------------
if ( ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] ) OR ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) OR ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) )
{
$endtime = IPSDebug::endTimer();
$_data = '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysqli_query($this->connection_id, "EXPLAIN {$the_query}");
$_bad = false;
while( $array = mysqli_fetch_array($eid) )
{
$array['extra'] = isset( $array['extra'] ) ? $array['extra'] : '';
$_data .= "\n+------------------------------------------------------------------------------+";
$_data .= "\n|Table: ". $array['table'];
$_data .= "\n|Type: ". $array['type'];
@@ -265,18 +269,18 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
$_data .= "\n|Rows: ". $array['rows'];
$_data .= "\n|Extra: ". $array['Extra'];
//$_data .= "\n+------------------------------------------------------------------------------+";
if ( ( $this->obj['use_bad_log'] AND $this->obj['bad_log'] ) AND stristr( $array['Extra'], 'filesort' ) OR stristr( $array['Extra'], 'temporary' ) )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['bad_log'], TRUE );
}
if ( ( $this->obj['use_slow_log'] AND $this->obj['slow_log'] ) AND $endtime >= $this->obj['use_slow_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime, $this->obj['slow_log'], TRUE );
}
}
if ( $this->obj['use_debug_log'] AND $this->obj['debug_log'] )
{
$this->writeDebugLog( $the_query, $_data, $endtime );
@@ -290,22 +294,22 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
}
}
}
//-----------------------------------------
// Debugging?
//-----------------------------------------
if ($this->obj['debug'])
{
$endtime = IPSDebug::endTimer();
$memoryUsed = IPSDebug::setMemoryDebugFlag( '', $_MEMORY );
$memory = '';
$shutdown = $this->is_shutdown ? 'SHUTDOWN QUERY: ' : '';
if ( preg_match( "/^(?:\()?select/i", $the_query ) )
{
$eid = mysqli_query( $this->connection_id, "EXPLAIN {$the_query}" );
$this->debug_html .= "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FFE8F3' align='center'>
<tr>
<td colspan='8' style='font-size:14px' bgcolor='#FFC5Cb'><b>{$shutdown}Select Query</b></td>
@@ -321,7 +325,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
while( $array = mysqli_fetch_array($eid) )
{
$type_col = '#FFFFFF';
if ($array['type'] == 'ref' or $array['type'] == 'eq_ref' or $array['type'] == 'const')
{
$type_col = '#D8FFD4';
@@ -330,7 +334,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$type_col = '#FFEEBA';
}
$this->debug_html .= "<tr bgcolor='#FFFFFF'>
<td>$array[table]&nbsp;</td>
<td bgcolor='$type_col'>$array[type]&nbsp;</td>
@@ -342,19 +346,19 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
<td>$array[Extra]&nbsp;</td>
</tr>\n";
}
$this->sql_time += $endtime;
if ($endtime > 0.1)
{
$endtime = "<span style='color:red'><b>$endtime</b></span>";
}
if ( $memoryUsed )
{
$memory = '<br />Memory Used: ' . IPSLib::sizeFormat( $memoryUsed, TRUE );
}
$this->debug_html .= "<tr>
<td colspan='8' bgcolor='#FFD6DC' style='font-size:14px'><b>MySQL time</b>: $endtime{$memory}</b></td>
</tr>
@@ -375,11 +379,11 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
</table><br />\n\n";
}
}
$this->query_count++;
$this->obj['cached_queries'][] = $the_query;
return $this->query_id;
}
@@ -393,7 +397,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysqli_affected_rows( $this->connection_id );
}
/**
* Retrieve number of rows in result set
*
@@ -410,7 +414,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
return mysqli_num_rows( $query_id );
}
/**
* Retrieve latest autoincrement insert id
*
@@ -421,7 +425,7 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
return mysqli_insert_id($this->connection_id);
}
/**
* Retrieve the current thread id
*
@@ -431,8 +435,8 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function getThreadId()
{
return mysqli_thread_id($this->connection_id);
}
}
/**
* Free result set from memory
*
@@ -446,10 +450,10 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
{
$query_id = $this->query_id;
}
@mysqli_free_result( $query_id );
}
/**
* Retrieve row from database
*
@@ -460,14 +464,14 @@ class db_driver_mysql extends db_main_mysql implements interfaceDb
public function fetch( $query_id=null )
{
//$_MEMORY = IPSDebug::getMemoryDebugFlag();
if ( ! $query_id )
{
$query_id = $this->query_id;
}
$this->record_row = mysqli_fetch_assoc( $query_id );
/*if ( is_array( $this->record_row ) )
{
$tmp = $this->record_row;
@@ -490,11 +494,13 @@ $this->_tmpT += $poo;*/
{
$calcRowsHandle = mysqli_query( $this->connection_id, "SELECT FOUND_ROWS() as " . $alias );
$val = mysqli_fetch_assoc( $calcRowsHandle );
$this->obj['cached_queries'][] = "SELECT FOUND_ROWS() as " . $alias;
$val = mysqli_fetch_assoc( $calcRowsHandle );
return intval( $val[ $alias ] );
}
/**
* Get array of fields in result set
*
@@ -505,17 +511,17 @@ $this->_tmpT += $poo;*/
public function getResultFields( $query_id=null )
{
$fields = array();
if ( !$query_id )
{
$query_id = $this->query_id;
}
while( $field = mysqli_fetch_field($query_id) )
{
$fields[] = $field;
}
return $fields;
}
@@ -531,14 +537,14 @@ $this->_tmpT += $poo;*/
{
return $this->cached_tables;
}
$current = $this->return_die;
$this->return_die = true;
$qid = $this->query( "SHOW TABLES FROM `{$this->obj['sql_database']}`" );
$this->return_die = $current;
if( $qid AND $this->getTotalRows($qid) )
{
while( $result = mysqli_fetch_array($qid) )
@@ -546,11 +552,11 @@ $this->_tmpT += $poo;*/
$this->cached_tables[] = $result[0];
}
}
mysqli_free_result($qid);
return $this->cached_tables;
}
}
/**
* Retrieve SQL server version
@@ -563,13 +569,13 @@ $this->_tmpT += $poo;*/
if ( ! $this->sql_version and ! $this->true_version )
{
$version = mysqli_get_server_info($this->connection_id);
$this->true_version = $version;
$tmp = explode( '.', preg_replace( "#[^\d\.]#", "\\1", $version ) );
$this->sql_version = sprintf('%d%02d%02d', $tmp[0], $tmp[1], $tmp[2] );
}
return $this->sql_version;
}
@@ -582,7 +588,7 @@ $this->_tmpT += $poo;*/
*/
public function addSlashes( $t )
{
return mysqli_real_escape_string( $this->connection_id, $t );
return @mysqli_real_escape_string( $this->connection_id, $t );
}
/**
@@ -602,7 +608,7 @@ $this->_tmpT += $poo;*/
return mysqli_errno( $this->connection_id );
}
}
/**
* Get SQL error message
*
@@ -610,7 +616,7 @@ $this->_tmpT += $poo;*/
* @return string Error message
*/
protected function _getErrorString()
{
{
if( $this->connect_failed )
{
return mysqli_connect_error( );
@@ -620,6 +626,6 @@ $this->_tmpT += $poo;*/
return mysqli_error( $this->connection_id );
}
}
} // end class
+22 -16
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Compare and highlight differences between two strings or files
* Last Updated: $Date: 2009-03-24 17:32:58 -0400 (Tue, 24 Mar 2009) $
* Last Updated: $Date: 2010-04-21 07:40:53 -0400 (Wed, 21 Apr 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Thursday 10th February 2005 (10:47)
* @version $Revision: 249 $
* @version $Revision: 394 $
*/
if ( ! defined( 'IPS_CLASSES_PATH' ) )
@@ -89,10 +92,13 @@ class classDifference
{
$this->diff_found = 0;
$str1 = $this->_diffTagSpace($str1);
$str2 = $this->_diffTagSpace($str2);
$str1_lines = $this->_diffExplodeStringIntoWords($str1);
$str2_lines = $this->_diffExplodeStringIntoWords($str2);
if ( $this->method != 'PHP' )
{
$str1 = $this->_diffTagSpace($str1);
$str2 = $this->_diffTagSpace($str2);
$str1_lines = $this->_diffExplodeStringIntoWords($str1);
$str2_lines = $this->_diffExplodeStringIntoWords($str2);
}
if ( $this->method == 'CGI' )
{
@@ -100,7 +106,7 @@ class classDifference
}
else if ( $this->method == 'PHP' )
{
$diff_res = $this->_getPhpDiff( implode( chr(10), $str1_lines ) . chr(10), implode( chr(10), $str2_lines ) . chr(10) );
$diff_res = $this->_getPhpDiff( $str1, $str2 );
}
else
{
@@ -227,7 +233,7 @@ class classDifference
* @return array Array of words in string
*/
private function _diffExplodeStringIntoWords( $str )
{
{
$str_array = $this->_explodeTrim( chr(10), $str );
$out_array = array();
@@ -282,7 +288,7 @@ class classDifference
* @return string
*/
private function _getPhpDiff( $str1 , $str2 )
{
{
$str1 = explode( "\n", str_replace( "\r\n", "\n", $str1 ) );
$str2 = explode( "\n", str_replace( "\r\n", "\n", $str2 ) );
@@ -318,8 +324,8 @@ class classDifference
$this->post_process = 0;
# Convert lines to a space, and two spaces to a single line
$result = str_replace(' ', chr(10), str_replace( "\n", " ", $result ) );
$result = $this->_diffTagSpace($result,1);
//$result = str_replace(' ', chr(10), str_replace( "\n", " ", $result ) );
//$result = $this->_diffTagSpace($result,1);
return $result;
}
+53 -36
View File
@@ -1,20 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Send email using php mail() or SMTP
* Last Updated: $Date: 2009-11-10 18:07:29 -0500 (Tue, 10 Nov 2009) $
* Last Updated: $Date: 2010-09-09 17:45:22 -0400 (Thu, 09 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
* @version $Revision: 343 $
* @version $Revision: 459 $
*
* @todo [Future] Support receiving and parsing emails and attachments
*
* Example usage:
* <code>
@@ -26,7 +28,7 @@
* 'charset' => 'utf-8',
* )
* );
* $email->setFrom( "dont@mail.me", "This is\r\nan email" );
* $email->setFrom( "support@invisionpower.com", "This is\r\nan email" );
* $email->setTo( "me@mydomain.com" );
* $email->addBCC( "myfriend@mydomain.com" );
* $email->addBCC( "myotherfriend@mydomain.com" );
@@ -457,8 +459,6 @@ class classEmail implements interfaceEmail
$this->parts = array();
$this->mail_headers = array();
$this->multipart = '';
$this->smtp_msg = '';
$this->smtp_code = '';
}
/**
@@ -631,7 +631,7 @@ class classEmail implements interfaceEmail
$this->_fatalError( "Пустое поле От, Кому или Тема" );
return false;
}
//-----------------------------------------
// Debugging
//-----------------------------------------
@@ -652,7 +652,7 @@ class classEmail implements interfaceEmail
return false;
}
$pathy = $this->temp_dump_path . '/' . date("M-j-Y,hi-A") . str_replace( '@', '+', $this->to ) . '.php';
$pathy = $this->temp_dump_path . '/' . date("M-j-Y") . '-' . time() . str_replace( '@', '+', $this->to ) . uniqid( '_' ) . '.php';
$fh = @fopen( $pathy, 'w' );
@fputs( $fh, $debug, strlen($debug) );
@@ -754,24 +754,34 @@ class classEmail implements interfaceEmail
// so we just strip board name and continue
//-----------------------------------------
if( $header == 'From' OR $header == 'Content-Type' OR $header == 'Content-Disposition' )
if( $header == 'From' OR $header == 'Content-Type' OR $header == 'Content-Disposition' OR $header == 'Content-Transfer-Encoding' OR $header == 'v' )
{
$this->mail_headers[ $header ] = $orig_value;
if ( ! count($headers) )
{
$this->mail_headers[ $header ] = $orig_value;
}
$enc_headers[ $header ] = $orig_value;
continue;
}
//-----------------------------------------
// We don't want to keep subject in the
// headers for php mail
//-----------------------------------------
if( $this->mail_method != 'smtp' AND $header == 'Subject' )
if( $header == 'Subject' OR $header == 'FDispay' )
{
$val= '=?' .$this->char_set .'?B?' .base64_encode($orig_value) .'?=';
if( !count($headers) )
{
$this->mail_headers[ $header ] = $val;
}
else
{
$enc_headers[ $header ] = $val;
}
continue;
}
//-----------------------------------------
// Don't bother encoding unless we have chars
// that need to be encoded
@@ -779,7 +789,11 @@ class classEmail implements interfaceEmail
if( !preg_match( '/(\w*[\x80-\xFF]+\w*)/', $value ) )
{
$this->mail_headers[ $header ] = $orig_value;
if( $header != 'Subject' )
{
$this->mail_headers[ $header ] = $orig_value;
}
$enc_headers[ $header ] = $orig_value;
continue;
@@ -802,7 +816,7 @@ class classEmail implements interfaceEmail
$value = preg_replace( "/" . $spacer . "$/", "", $value );
$value = $start . $value . $end;
if( !count($headers) )
if( !count($headers) AND ( $this->mail_method == 'smtp' OR $header != 'Subject' ) )
{
$this->mail_headers[ $header ] = $value;
}
@@ -855,6 +869,7 @@ class classEmail implements interfaceEmail
//-----------------------------------------
// From and to...
// @link http://community.invisionpower.com/tracker/issue-22474-mail-delivery-method-character/
//-----------------------------------------
if( $this->from_display AND !preg_match( '/(\w*[\x80-\xFF]+\w*)/', $this->from_display ) )
@@ -940,7 +955,7 @@ class classEmail implements interfaceEmail
$extra_headers[1]['Content-Type'] = "text/plain;\n\tcharset=\"".$this->char_set."\"";
$extra_headers[1]['notencode'] = "\n\n".$this->pt_message."\n\n--".$this->boundry."\n";
$extra_headers[2]['Content-Type'] = "text/html;\n\tcharset=\"".$this->char_set."\"";
$extra_headers[2]['notencode'] = "\n\n".$this->message."\n\n";
$extra_headers[2]['notencode'] = "\n\n".$this->message."\n\n--".$this->boundry."--";
reset($extra_headers);
@@ -954,13 +969,15 @@ class classEmail implements interfaceEmail
}
else
{
$v = $this->_encodeHeaders( array( 'v' => $v ) );
$v = $this->_encodeHeaders( array( $k => $v ) );
$extra_headers_rfc .= $k . ': ' . $v['v'] . self::header_eol;
$extra_headers_rfc .= $k . ': ' . $v[ $k ] . self::header_eol;
}
}
}
unset( $this->mail_headers['Content-Type'] );
$this->message = "";
}
else
@@ -1075,6 +1092,14 @@ class classEmail implements interfaceEmail
*/
private function _smtpDisconnect()
{
$this->_smtpSendCmd( "quit" );
if ( $this->smtp_code != 221 )
{
$this->_smtpError( "Невозможно уйти с SMTP сервера с помощью 'quit'" );
return false;
}
return @fclose( $this->smtp_fp );
}
@@ -1145,7 +1170,7 @@ class classEmail implements interfaceEmail
*/
private function _smtpError( $err="" )
{
$this->smtp_msg = $err;
//$this->smtp_msg = $err;
$this->_fatalError( $err );
return false;
}
@@ -1242,14 +1267,6 @@ class classEmail implements interfaceEmail
$this->_smtpError( "Ошибка отправки письма" );
return false;
}
$this->_smtpSendCmd( "quit" );
if ( $this->smtp_code != 221 )
{
$this->_smtpError( "Невозможно уйти с SMTP сервера с помощью 'quit'" );
return false;
}
}
+107 -17
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Wrapper for retrieving file contents. Methods available for removing files and directories as well.
* Last Updated: $Date: 2009-12-02 21:34:26 -0500 (Wed, 02 Dec 2009) $
* Last Updated: $Date: 2010-06-24 05:35:43 -0400 (Thu, 24 Jun 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Tuesday 22nd February 2005 (16:55)
* @version $Revision: 350 $
* @version $Revision: 432 $
*/
if ( ! defined( 'IPS_CLASSES_PATH' ) )
@@ -46,18 +49,30 @@ class classFileManagement
*
* @access public
* @var integer HTTP Status code
* @var string HTTP Status text
*/
public $http_status_code = 0;
/**
* HTTP Status Code/Text
*
* @access public
* @var string HTTP Status text
*/
public $http_status_text = "";
/**
* Raw HTTP header output
*
* @access public
* @var string Raw HTTP header results
*/
public $raw_headers = '';
/**#@+
* Set Authentication
*
* @access public
* @var string
* @var string
* @var string
* @var string
*/
public $auth_req = 0;
public $auth_user;
@@ -220,7 +235,7 @@ class classFileManagement
$host = $url_parts['host'];
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' ? 443 : 80 );
//-------------------------------
// Tidy up path
//-------------------------------
@@ -243,7 +258,7 @@ class classFileManagement
// Open connection
//-------------------------------
if ( ! $fp = @fsockopen( $host, $port, $errno, $errstr, $fsocket_timeout ) )
if ( ! $fp = @fsockopen( $url_parts['scheme'] == 'https' ? "ssl://" . $host : $host, $port, $errno, $errstr, $fsocket_timeout ) )
{
$this->errors[] = "Не могу установить соединение с {$host}";
return FALSE;
@@ -309,10 +324,12 @@ class classFileManagement
{
$_chunked = true;
}
$tmp = split("\r\n\r\n", $data, 2);
$tmp = preg_split("/\r\n\r\n/", $data, 2);
$data = trim($tmp[1]);
$this->raw_headers = trim($tmp[0]);
//-----------------------------------------
// Easy way out :P
//-----------------------------------------
@@ -341,12 +358,14 @@ class classFileManagement
{
$ch = curl_init( $file_location );
curl_setopt( $ch, CURLOPT_HEADER , 0);
curl_setopt( $ch, CURLOPT_HEADER , 1);
curl_setopt( $ch, CURLOPT_TIMEOUT , $this->timeout );
curl_setopt( $ch, CURLOPT_POST , 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FAILONERROR , 1 );
curl_setopt( $ch, CURLOPT_MAXREDIRS , 10 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER , false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST , 1 );
/**
* Cannot set this when safe_mode or open_basedir is enabled
@@ -364,7 +383,15 @@ class classFileManagement
$data = curl_exec($ch);
curl_close($ch);
if( $data )
{
$tmp = preg_split("/\r\n\r\n/", $data, 2);
$data = trim($tmp[1]);
$this->raw_headers = trim($tmp[0]);
}
if ( $data )
{
$this->http_status_code = 200;
@@ -378,6 +405,69 @@ class classFileManagement
}
}
/**
* Tail a file
*
* @access public
* @param string Full path to file
* @param int No. lines to tail
*/
public function tailFile( $file, $lines=100 )
{
/* INIT */
$content = '';
$t = array();
if ( file_exists( $file ) )
{
$handle = @fopen( $file, 'r' );
if ( $handle )
{
$l = $lines;
$pos = -2;
$beg = false;
while ( $l > 0 )
{
$_t = " ";
while( $_t != "\n" )
{
if ( @fseek( $handle, $pos, SEEK_END ) == -1 )
{
$beg = true;
break;
}
$_t = @fgetc( $handle );
$pos--;
}
$l--;
if ( $beg )
{
rewind( $handle );
}
$t[ $lines - $l - 1 ] = @fgets( $handle );
if ( $beg )
{
break;
}
}
@fclose ($handle);
$content = trim( implode( "", array_reverse( $t ) ) );
}
}
return $content;
}
/**
* Copies contents of one directory to another, creating if necessary
*
File diff suppressed because it is too large. Load diff
+39 -8
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Image Handler: create thumbnails, apply watermarks and copyright tests, save or display final image
* Last Updated: $Date: 2009-06-12 22:35:26 -0400 (Fri, 12 Jun 2009) $
* Last Updated: $Date: 2010-11-10 11:27:28 -0500 (Wed, 10 Nov 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 5th May 2008 14:00
* @version $Revision: 282 $
* @version $Revision: 485 $
*
* GD Example
* <code>
@@ -36,6 +39,34 @@
* </code>
*/
/**
* Bootstrapper
* Picks GD or imagemagik
*/
class ips_kernel_image
{
/**
* Loads correct class
* @param string $load
* @return Ambigous <classImageImagemagick, classImageGd>
*/
static public function bootstrap( $load='gd' )
{
if ( $load == 'im' )
{
require_once( IPS_KERNEL_PATH . 'classImageImagemagick.php' );
$img = new classImageImagemagick();
}
else
{
require_once( IPS_KERNEL_PATH . 'classImageGd.php' );
$img = new classImageGd();
}
return $img;
}
}
/**
* Image interface
*
@@ -266,7 +297,7 @@ abstract class classImage
// Is the current image already smaller?
//---------------------------------------------------------
if( $width > $this->cur_dimensions['width'] AND $height > $this->cur_dimensions['height'] )
if( $width >= $this->cur_dimensions['width'] AND $height >= $this->cur_dimensions['height'] )
{
$this->error = 'already_smaller';
return false;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+433
View File
@@ -0,0 +1,433 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Parse Incoming Emails
* Last Updated: $Date: 2010-11-15 10:45:42 -0500 (Mon, 15 Nov 2010) $
* </pre>
*
* @author $Author: mark $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 25th June 2010
* @version $Revision: 486 $
*/
class classIncomingEmail
{
/**
* Recipient Address
*
* @var string
* @see __construct
*/
public $to;
/**
* Sender Address
*
* @var string
* @see __construct
*/
public $from;
/**
* Subject
*
* @var string
* @see __construct
*/
public $subject;
/**
* Message Body
*
* @var string
* @see __construct
*/
public $message;
/**
* Attachments
* This is an associative array of attachment data.
* The keys are IDs which are associated with <!--ATTACHMENT:{key}--> taks in $this->body.
* The values are an array of data to insert into the attachments database table after attach_member_id and attach_rel_module have been set.
*
* @var array
* @see __construct
*/
public $attachments;
/**
* Constructor
* Sets $this->to, $this->from, $this->subject, $this->message and $this->attachments
*
* @param string Raw message with headers
*/
public function __construct( $email )
{
//--------------------------------------
// Get some stuff
//--------------------------------------
if ( class_exists( 'ipsRegistry' ) )
{
$this->DB = ipsRegistry::DB();
// Fetch upload path
$this->upload_dir = ipsRegistry::$settings['upload_dir'];
$this->upload_url = ipsRegistry::$settings['upload_url'];
}
else
{
$this->initDB();
// Fetch upload path
$this->DB->build( array( 'select' => 'conf_key,conf_value', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='upload_dir' OR conf_key='upload_url'" ) );
$this->DB->execute();
while ( $r = $this->DB->fetch() )
{
if ( $r['conf_key'] == 'upload_dir' )
{
$this->upload_dir = $r['conf_value'];
}
elseif ( $r['conf_key'] == 'upload_url' )
{
$this->upload_url = $r['conf_value'];
}
}
}
// And allowed attachment types
$this->types = array();
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type' ) );
$this->DB->execute();
while ( $r = $this->DB->fetch() )
{
$this->types[ $r['atype_mimetype'] ][] = $r;
}
//--------------------------------------
// Pass to PEAR
//--------------------------------------
// It raises strict warnings
@error_reporting( E_NONE );
@ini_set( 'display_errors', 'off' );
require_once ( IPS_KERNEL_PATH . 'PEAR/Mail/mimeDecode.php' );
$decoder = new Mail_mimeDecode( $email );
$mail = $decoder->decode( array(
'include_bodies' => TRUE,
'decode_bodies' => TRUE,
'decode_headers' => TRUE,
) );
//--------------------------------------
// Parse Headers
//--------------------------------------
/* To */
if ( $mail->headers['delivered-to'] )
{
$mail->headers['to'] = $mail->headers['delivered-to'];
}
$to = array();
if ( strpos( $mail->headers['to'], ',' ) === FALSE )
{
$mail->headers['to'] = array( $mail->headers['to'] );
}
else
{
$mail->headers['to'] = explode( ',', $mail->headers['to'] );
}
foreach ( $mail->headers['to'] as $_to )
{
if ( preg_match( "/.+? <(.+?)>/", $_to, $matches ) )
{
$to[] = $matches[1];
}
else
{
$to[] = trim( $_to, '<>' );
}
}
$this->to = implode( ',', $to );
/* From */
if ( preg_match( "/.+? <(.+?)>/", $mail->headers['from'], $matches ) )
{
$this->from = $matches[1];
}
else
{
$this->from = trim( $mail->headers['from'], '<>' );
}
/* Subject */
$this->subject = $mail->headers['subject'] ? $mail->headers['subject'] : '(No Subject)';
//--------------------------------------
// Parse Body
//--------------------------------------
$this->message = '';
$this->attachments = array();
$akey = 0;
/* Normal message */
if ( $mail->ctype_primary == 'text' )
{
if ( $mail->ctype_secondary == 'html' )
{
$this->message = str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( strip_tags( $mail->body ) ) );
}
else
{
$this->message = str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( $mail->body ) );;
}
}
/* Normal message, sent in both HTML and normal */
elseif ( $mail->ctype_primary == 'multipart' AND $mail->ctype_secondary == 'alternative' )
{
$this->message = '';
foreach ( $mail->parts as $part )
{
if ( $part->ctype_secondary == 'html' )
{
$this->message = str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( strip_tags( $part->body ) ) );;
}
else
{
$this->message = str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( $part->body ) );;
if ( $part->ctype_secondary == 'plain' )
{
break;
}
}
}
}
/* Multipart message (with attachments and stuff) */
else
{
foreach ( $mail->parts as $part )
{
if ( $part->ctype_primary == 'multipart' AND $part->ctype_secondary == 'alternative' )
{
$add = '';
foreach ( $part->parts as $subpart )
{
$add = str_replace( array( "\n", "\r", "\r\n" ), '<br />', $subpart->body );
if ( $subpart->ctype_secondary == 'plain' )
{
break;
}
}
$this->message .= $add;
}
elseif ( $part->ctype_primary == 'text' )
{
if ( $part->ctype_secondary == 'html' )
{
$this->message .= str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( strip_tags( $part->body ) ) );;
}
else
{
$this->message .= str_replace( array( "\n", "\r", "\r\n" ), '<br />', htmlentities( $part->body ) );;
}
}
else
{
$mime = "{$part->ctype_primary}/{$part->ctype_secondary}";
foreach ( $this->types[ $mime ] as $data )
{
$name_parts = explode( '.', $part->ctype_parameters['name'] );
$ext = array_pop( $name_parts );
if ( $data['atype_extension'] == $ext and $data['atype_post'] )
{
/* Create the file */
$masked_name = md5( uniqid( 'email' ) ) . "-{$part->ctype_parameters['name']}";
while ( file_exists( $this->upload_dir . "/{$masked_name}" ) )
{
$masked_name = md5( uniqid( 'email' ) . microtime() ) . "-{$part->ctype_parameters['name']}";
}
file_put_contents( $this->upload_dir . "/{$masked_name}", $part->body );
/* Store attachment data */
$akey++;
$this->attachments[ $akey ] = array(
'attach_ext' => $ext,
'attach_file' => $part->ctype_parameters['name'],
'attach_location' => $masked_name,
'attach_is_image' => ( $part->ctype_primary == 'image' ) ? 1 : 0,
'attach_date' => time(),
'attach_filesize' => $part->d_parameters['size'],
);
$this->message .= "<!--ATTACHMENT:{$akey}-->";
break;
}
}
}
}
}
}
/**
* Route
* Uses incoming Email rules to route Email
*/
public function route()
{
$unrouted = TRUE;
$this->DB->build( array( 'select' => '*', 'from' => 'core_incoming_emails' ) );
$this->DB->execute();
while ( $row = $this->DB->fetch() )
{
switch ( $row['rule_criteria_field'] )
{
case 'to':
$analyse = $this->to;
break;
case 'from':
$analyse = $this->from;
break;
case 'sbjt':
$analyse = $this->subject;
break;
case 'body':
$analyse = $this->message;
break;
}
$match = false;
switch ( $row['rule_criteria_type'] )
{
case 'ctns':
$match = (bool) ( strpos( $analyse, $row['rule_criteria_value'] ) !== FALSE );
break;
case 'eqls':
if ( strpos( $analyse, ',' ) !== FALSE )
{
$match = (bool) in_array( $analyse, explode( ',', $analyse ) );
}
else
{
$match = (bool) ( $analyse == $row['rule_criteria_value'] );
}
break;
case 'regx':
$match = (bool) ( preg_match( "/{$row['rule_criteria_value']}/", $analyse ) == 1 );
break;
}
if ( $match )
{
$unrouted = FALSE;
if ( $row['rule_app'] != '--' )
{
$appdir = IPS_ROOT_PATH . 'applications_addon/ips/' . $row['rule_app'];
if ( !is_dir( $appdir ) )
{
$appdir = IPS_ROOT_PATH . 'applications_addon/other/' . $row['rule_app'];
}
if ( !is_dir( $appdir ) )
{
$appdir = IPS_ROOT_PATH . 'applications/' . $row['rule_app'];
}
if ( file_exists( $appdir . '/extensions/incomingEmails.php' ) )
{
$class = 'incomingEmails_' . $row['rule_app'];
require_once $appdir . '/extensions/incomingEmails.php';
$class = new $class;
$class->process( $this->DB, $this->to, $this->from, $this->subject, $this->message, $this->attachments );
}
}
break;
}
}
if ( $unrouted )
{
$apps = array();
foreach ( glob( IPS_ROOT_PATH . 'applications/*' ) as $f )
{
if ( file_exists( $f . '/extensions/incomingEmails.php' ) )
{
$bits = explode( '/', $f );
$_appdir = array_pop( $bits );
$apps[ $_appdir ] = $f;
}
}
foreach ( glob( IPS_ROOT_PATH . 'applications_addon/ips/*' ) as $f )
{
if ( file_exists( $f . '/extensions/incomingEmails.php' ) )
{
$bits = explode( '/', $f );
$_appdir = array_pop( $bits );
$apps[ $_appdir ] = $f;
}
}
foreach ( glob( IPS_ROOT_PATH . 'applications_addon/other/*' ) as $f )
{
if ( file_exists( $f . '/extensions/incomingEmails.php' ) )
{
$bits = explode( '/', $f );
$_appdir = array_pop( $bits );
$apps[ $_appdir ] = $f;
}
}
foreach ( $apps as $_appdir => $appdir )
{
require_once $appdir . '/extensions/incomingEmails.php';
$class = 'incomingEmails_' . $_appdir;
$i = new $class;
if ( $i->handleUnrouted( $this->DB, $this->to, $this->from, $this->subject, $this->message, $this->attachments ) )
{
break;
}
}
}
}
/**
* Init DB
* Since this class may be being called when ipsRegistry
* is not set up, we may need to create a DB object
*
* @see route()
*/
private function initDB()
{
/* Init */
$INFO = array();
@require( DOC_IPS_ROOT_PATH . 'conf_global.php' );
$this->DB_driver = strtolower( $INFO['sql_driver'] );
require_once ( IPS_KERNEL_PATH . 'classDb' . ucwords( $this->DB_driver ) . ".php" );
$classname = "db_driver_" . $this->DB_driver;
$this->DB = new $classname;
$this->DB->obj['sql_database'] = $INFO['sql_database'];
$this->DB->obj['sql_user'] = $INFO['sql_user'];
$this->DB->obj['sql_pass'] = $INFO['sql_pass'];
$this->DB->obj['sql_host'] = $INFO['sql_host'];
$this->DB->obj['sql_charset'] = $INFO['sql_charset'];
$this->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'] ? $INFO['sql_tbl_prefix'] : '';
$this->DB->connect();
}
}
+503
View File
@@ -0,0 +1,503 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Three Way Merge Class
* Last Updated: $Date: 2009-02-04 20:03:59 +0000 (Wed, 04 Feb 2009) $ BY $author$
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 3887 $
*
*/
class ThreeWayMerge
{
/**
* Original text
* For example, template bit from 3.0.5
*
* @access private
*/
private $_ORIG = array();
/**
* New text
* For example, template bit from 3.1.0
*
* @access private
*/
private $_NEW = array();
/**
* Custom text
* For example, user customized template bit
*
* @access private
*/
private $_CUSTOM = array();
/**
* Debug messages
*
* @access public
*/
public $DEBUG = array();
public $diffType = 'lite';
/**
* Construct
*
* @param string Original Text
* @param string New Text
* @param string Custom Text
*/
public function __construct( $ORIG, $NEW, $CUSTOM, $mType='lite' )
{
$this->_ORIG = ( ! is_array( $ORIG ) ) ? explode( "\n", str_replace( "\r\n", "\n", trim( $ORIG ) ) ) : $ORIG;
$this->_NEW = ( ! is_array( $NEW ) ) ? explode( "\n", str_replace( "\r\n", "\n" , trim( $NEW ) ) ) : $NEW;
$this->_CUSTOM = ( ! is_array( $CUSTOM ) ) ? explode( "\n", str_replace( "\r\n", "\n" , trim( $CUSTOM ) ) ) : $CUSTOM;
if ( $mType != 'lite' )
{
$this->diffType = $mType;
}
/* Set include path.. */
@set_include_path( IPS_KERNEL_PATH . 'PEAR/' );
/* OMG.. too many PHP 5 errors under strict standards */
if ( IN_DEV )
{
$oldReportLevel = error_reporting( 0 );
error_reporting( $oldReportLevel ^ E_STRICT );
}
else
{
error_reporting( 0 );
}
/* ugh */
if ( $this->diffType == 'lite' )
{
require_once 'Text/Diff3.php';
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer/inline.php';
}
else
{
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer/ips3waymerge.php';
}
}
/**
* Merge
*
* @access public
* @return string Merged string
*
* On conflict, will throw an exception with a message of CONFLICT
*/
public function merge()
{
$this->_addDebugMsg( '---- START--o---', $this->_ORIG );
$this->_addDebugMsg( '---- START--n---', $this->_NEW );
$this->_addDebugMsg( '---- START--c---', $this->_CUSTOM );
if ( $this->diffType == 'lite' )
{
/* Create the Diff object. */
$diff = new Text_Diff3( $this->_ORIG, $this->_NEW, $this->_CUSTOM );
/* Output the diff in unified format. */
return $this->_postProcessQuick( implode( "\n", $diff->mergedOutput( 'XXXNEWXXX', 'XXXCUSTOMXXX' ) ) );
}
else
{
/* ORIG - NEW */
$diff = new Text_Diff( 'auto', array( $this->_ORIG, $this->_NEW ) );
$renderer = new Text_Diff_Renderer_ips3waymerge();
$orig_new = explode( "\n", trim( $renderer->render($diff) ) );
/* ORIG - CUSTOM */
$diff = new Text_Diff( 'auto', array( $this->_ORIG, $this->_CUSTOM ) );
$renderer = new Text_Diff_Renderer_ips3waymerge();
$orig_custom = explode( "\n", trim( $renderer->render($diff) ) );
/* Process the arrays */
$orig_new_map = $this->_fetchProcessed( $orig_new, 1 );
$orig_custom_map = $this->_fetchProcessed( $orig_custom );
/* Add to debug */
$this->_addDebugMsg( '---- OLD DEFAULT------', $this->_ORIG );
$this->_addDebugMsg( '---- NEW DEFAULT------', $this->_NEW );
$this->_addDebugMsg( '---- USER DEFAULT------', $this->_CUSTOM );
$this->_addDebugMsg( '---- OLD DEFAULT > NEW DEFAULT DIFF------', $orig_new_map );
$this->_addDebugMsg( '---- OLD DEFAULT > USER CUSTOM DIFF------', $orig_custom_map );
/* Process the thing */
try
{
$return = $this->_processMerge( $orig_new_map, $orig_custom_map );
return $return;
}
catch( Exception $e )
{
throw new Exception( $e->getMessage() );
}
}
}
/**
* Post process merge (quick)
*
* @access private
* @param string Merge text
* @return string processed text
*/
private function _postProcessQuick( $text )
{
/* INIT */
$count = 0;
//print $text; exit();
/* MATCH */
preg_match_all( "#<<<<<<< XXXNEWXXX(.+?)=======(.+?)>>>>>>> XXXCUSTOMXXX#si", $text, $matches );
if ( is_array($matches) AND count($matches) )
{
foreach( $matches[1] as $index => $m )
{
/* Yeah, I like readable code and copying and pasting evidently */
$_all = $matches[0][$index];
$_new = trim( $matches[1][$index], "\n" );
$_custom = trim( $matches[2][$index], "\n" );
$_new = "<ips:conflict id=\"{$count}\">\n<ips:cblock type=\"original\">\n" . $_custom . "\n</ips:cblock>\n<ips:cblock type=\"new\">\n" . $_new . "\n</ips:cblock>\n</ips:conflict>";
$text = str_replace( $_all, $_new, $text );
$count++;
}
}
return $text;
}
/**
* Process merge
* Takes the two maps (old-new, old-custom) and merges.
* Will throw an error on conflict.
*
* @access private
* @param array old-new map
* @param array old-custom map
* @return string
*/
private function _processMerge( $orig_new_map, $orig_custom_map )
{
$len = count( $this->_ORIG );
$c = 0;
$conflict = 0;
$final = array();
while( $c <= $len )
{
$left = $this->_sliceFromLineNumber( $orig_new_map, $c );
$right = $this->_sliceFromLineNumber( $orig_custom_map, $c );
if ( $left['type'] == 'ok' AND $right['type'] == 'ok' )
{
$test1 = $this->_textToAddAtLine( $orig_new_map, $c );
$test2 = $this->_textToAddAtLine( $orig_custom_map, $c );
/* Potential conflict, are both modifications to this line the same? */
if ( count( $test1 ) AND count( $test2 ) AND implode( "\n", $test1 ) != implode( "\n", $test2 ) )
{
$conflict++;
$final[] = "<ips:conflict id=\"{$conflict}\">";
$final[] = "<ips:cblock type=\"original\">";
if ( count( $test2 ) )
{
foreach( $test2 as $t )
{
$final[] = $t;
}
}
$final[] = "</ips:cblock>";
$final[] = "<ips:cblock type=\"new\">";
if ( count( $test1 ) )
{
foreach( $test1 as $t )
{
$final[] = $t;
}
}
$final[] = "</ips:cblock>";
$final[] = "</ips:conflict>";
}
else
{
if ( count( $test1 ) )
{
foreach( $test1 as $t )
{
$final[] = $t;
}
}
if ( count( $test2 ) )
{
foreach( $test2 as $t )
{
//$final[] = $t;
}
}
$final[] = $left['data'];
}
}
else if ( $left['type'] == 'del' AND $right['type'] == 'ok' )
{
/* Add in anything from left */
$final = $this->_textToAddAtLine( $orig_new_map, $c, $final, 'lnxx' );
/* One line or more exists in both? */
$final = $this->_textToAddAtLine( $orig_custom_map, $c, $final, 'lc--' );
}
else if ( $left['type'] == 'ok' AND $right['type'] == 'del' )
{
/* Add in right */
$final = $this->_textToAddAtLine( $orig_custom_map, $c, $final, 'rcxx' );
/* Anything to add from the new side? */
$final = $this->_textToAddAtLine( $orig_new_map, $c, $final, 'rn--' );
}
else if ( $left['type'] == 'del' AND $right['type'] == 'del' )
{
$test1 = $this->_textToAddAtLine( $orig_new_map, $c );
$test2 = $this->_textToAddAtLine( $orig_custom_map, $c );
/* Potential conflict, are both modifications to this line the same? */
if ( count( $test1 ) AND count( $test2 ) AND implode( "\n", $test1 ) != implode( "\n", $test2 ) )
{
$conflict++;
$final[] = "<ips:conflict id=\"{$conflict}\">";
$final[] = "<ips:cblock type=\"original\">";
if ( count( $test2 ) )
{
foreach( $test2 as $t )
{
$final[] = $t;
}
}
$final[] = "</ips:cblock>";
$final[] = "<ips:cblock type=\"new\">";
if ( count( $test1 ) )
{
foreach( $test1 as $t )
{
$final[] = $t;
}
}
$final[] = "</ips:cblock>";
$final[] = "</ips:conflict>";
}
else
{
if ( count( $test1 ) )
{
foreach( $test1 as $t )
{
/* We're removing, dumbass */
//$final[] = $c . ' dexx1' . $t;
}
}
if ( count( $test2 ) )
{
foreach( $test2 as $t )
{
/* We're removing, dumbass */
//$final[] = $c . ' dexx2 ' . $t;
}
}
}
}
$c++;
}
return implode( "\n", $final );
}
/**
* Returns an array slice for the ORIG line number X
*
* @access private
* @param array Re-processed Diff Array
* @param int ORIG line number
* @return array
*/
private function _sliceFromLineNumber( $data, $n )
{
foreach ( $data as $i )
{
if ( $i['line'] == $n AND $i['type'] != 'ins' )
{
return $i;
}
}
return false;
}
/**
* Returns an array of lines to add at the current ORIG line number X
*
* @access private
* @param array Re-processed Diff Array
* @param int ORIG line number
* @param array Array to add to
* @return array
*/
private function _textToAddAtLine( $data, $n, $return=array(), $p='' )
{
$return = ( is_array( $return ) AND count( $return ) ) ? $return : array();
foreach ( $data as $i )
{
if ( $i['line'] == $n AND $i['type'] == 'ins' )
{
$return[] = $i['data'];
}
}
return $return;
}
/**
* Re-process DIFF.
* Figures out mappings to original line numbers, etc
*
* @access private
* @param array Array of DIFF data
* @return array
*/
private function _fetchProcessed( $data, $log=0 )
{
/* Counter to ensure unique entry in $return */
$c = 0;
/* Counter to keep a corrilation with the original line numbering */
$n = 0;
/* Variable to retain value of $n when processing insertion rows */
$old_n = 0;
/* Flag to note if the previous row was a delete and therefore treat a proceeding insert as a replacement */
$delete_was_last = 0;
/* Freeze the line number when we first see a delete line (assume that more may follow if removing a block */
$freeze = 0;
foreach( $data as $l )
{
if ( substr( $l, 0, 1 ) == '+' )
{
/* AAA: If the last line was a delete, this is treated as a replacement */
if ( $delete_was_last )
{
/* We want to ensure that the insert retains the same ORIGINAL line number as the FIRST line of the recent delete(s)
So we effectively 'freeze' N for the inserts and store what would be the next number in $old_n */
$old_n = ( $old_n ) ? $old_n : $n;
$n = $freeze;
}
else if ( $freeze )
{
/* Ok, the previous was an insert after a delete line, so use the line number that would have been the first delete line number */
$n = $old_n;
}
$return[ $c ] = array( 'data' => substr( $l, 1 ),
'type' => 'ins',
'line' => $n );
/* Delete was not last. Reset freeze flag */
$delete_was_last = 0;
$freeze = 0;
}
else if ( substr( $l, 0, 1 ) == '-' )
{
$return[ $c ] = array( 'data' => substr( $l, 1 ),
'type' => 'del',
'line' => $n );
/* We want to 'freeze' the line number if this is the first delete line */
$freeze = ( $delete_was_last ) ? $freeze : $n;
/* AAA: We've just deleted a line, so flag this up because if an insert is next, then it's a replacement */
$delete_was_last = 1;
/* BBB: We deleted a line from the original, so increment the original line number */
$n++;
}
else
{
/* If this is a line after an insert or delete, use the old_n line number */
if ( $old_n )
{
$n = $old_n;
}
$return[ $c ] = array( 'data' => $l,
'type' => 'ok',
'line' => $n );
$n++;
$delete_was_last = 0;
$freeze = 0;
$old_n = 0;
}
$c++;
}
//print_r( $return );
return $return;
}
/**
* Add debug messages
*
* @access private
* @param string TITLE
* @param mixed Data
*/
private function _addDebugMsg( $title, $data )
{
$this->_DEBUG[] = $title . "\n" . var_export( $data, TRUE );
}
}
+260 -236
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* RSS handler: handles importing of RSS documents and exporting of RSS v2 documents
* Last Updated: $Date: 2009-08-17 20:55:40 -0400 (Mon, 17 Aug 2009) $
* Last Updated: $Date: 2010-04-19 18:35:00 -0400 (Mon, 19 Apr 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Monday 5th May 2008 14:00
* @version $Revision: 314 $
* @version $Revision: 392 $
*
* EXAMPLE: (CREATING AN RSS FEED)
* <code>
@@ -80,51 +83,51 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
class classRss
{
/**
* Class file management object
*
* @access public
* @var object
*/
* Class file management object
*
* @access public
* @var classFileManagement
*/
public $classFileManagement;
/**
* DOC type
*
* @access public
* @var string
*/
* DOC type
*
* @access public
* @var string
*/
public $doc_type = 'UTF-8';
/**
* Original DOC type
*
* @access public
* @var string
*/
* Original DOC type
*
* @access public
* @var string
*/
public $orig_doc_type = "";
/**
* Error capture
*
* @access public
* @var array
*/
* Error capture
*
* @access public
* @var array
*/
public $errors = array();
/**
* Use sockets flag
*
* @access public
* @var integer
*/
* Use sockets flag
*
* @access public
* @var integer
*/
public $use_sockets = 0;
/**#@+
* Work item
*
* @access private
* @var integer
*/
* Work item
*
* @access private
* @var integer
*/
private $in_item = 0;
private $in_image = 0;
private $in_channel = 0;
@@ -137,11 +140,11 @@ class classRss
/**#@-*/
/**#@+
* RSS Items
*
* @access private
* @var array
*/
* RSS Items
*
* @access private
* @var array
*/
public $rss_items = array();
private $rss_headers = array();
private $rss_images = array();
@@ -149,11 +152,11 @@ class classRss
/**#@-*/
/**#@+
* RSS Parse Items
*
* @access private
* @var string
*/
* RSS Parse Items
*
* @access private
* @var string
*/
private $rss_title;
private $rss_description;
private $rss_link;
@@ -165,11 +168,11 @@ class classRss
/**#@-*/
/**#@+
* RSS Parse Images
*
* @access private
* @var string
*/
* RSS Parse Images
*
* @access private
* @var string
*/
private $rss_img_url;
private $rss_img_title;
private $rss_img_link;
@@ -179,11 +182,11 @@ class classRss
/**#@-*/
/**#@+
* RSS Channel items
*
* @access private
* @var string
*/
* RSS Channel items
*
* @access private
* @var string
*/
private $rss_chan_title;
private $rss_chan_link;
private $rss_chan_desc;
@@ -192,73 +195,81 @@ class classRss
/**#@-*/
/**#@+
* Create: Channels
*
* @access private
* @var array
*/
* Create: Channels
*
* @access private
* @var array
*/
private $channels = array();
private $items = array();
private $channel_images = array();
/**#@-*/
/**#@+
* Set Authentication
*
* @access public
* @var strings
*/
* Set Authentication
*
* @access public
* @var string
*/
public $auth_req = 0;
public $auth_user;
public $auth_pass;
/**#@-*/
/**
* Final RSS Document
*
* @access public
* @var string
*/
* Final RSS Document
*
* @access public
* @var string
*/
public $rss_document = '';
/**
* Convert char set
*
* @access public
* @var integer
*/
* Convert char set
*
* @access public
* @var integer
*/
public $convert_charset = 0;
/**
* Convert newlines
*
* @access public
* @var integer
*/
* Convert newlines
*
* @access public
* @var integer
*/
public $collapse_newlines = 0;
/**
* Destination charset
*
* @access public
* @var string
*/
* Destination charset
*
* @access public
* @var string
*/
public $destination_charset = 'UTF-8';
/**
* Feed char set
*
* @access public
* @var string
*/
* Feed char set
*
* @access public
* @var string
*/
public $feed_charset = 'UTF-8';
/**
* HTML decoding needed
*
* @access protected
* @var bool
*/
protected $htmlDecodingNeeded = false;
/**
* Constructor
*
* @access public
* @return void
*/
* Constructor
*
* @access public
* @return void
*/
public function __construct()
{
$this->rss_tag_names = array( 'ITEM' => 'ITEM',
@@ -286,11 +297,11 @@ class classRss
}
/**
* Create the RSS document
*
* @access public
* @return void
*/
* Create the RSS document
*
* @access public
* @return void
*/
public function createRssDocument( )
{
if ( ! count( $this->channels ) )
@@ -398,15 +409,15 @@ class classRss
}
/**
* Create RSS 2.0 document: Add channel
*
* title, link, description,language,pubDate,lastBuildDate,docs,generator
* managingEditor,webMaster
*
* @access public
* @param array Data to add
* @return integer New channel ID
*/
* Create RSS 2.0 document: Add channel
*
* title, link, description,language,pubDate,lastBuildDate,docs,generator
* managingEditor,webMaster
*
* @access public
* @param array Data to add
* @return integer New channel ID
*/
public function createNewChannel( $in=array() )
{
$this->channels[ $this->cur_channel ] = $in;
@@ -423,42 +434,42 @@ class classRss
}
/**
* Create RSS 2.0 document: Add channel image item
*
* url, link, title, width, height, description
*
* @access public
* @param integer Channel ID
* @param array Array of image variables
* @return void
*/
* Create RSS 2.0 document: Add channel image item
*
* url, link, title, width, height, description
*
* @access public
* @param integer Channel ID
* @param array Array of image variables
* @return void
*/
public function addImageToChannel( $channel_id=0, $in=array() )
{
$this->channel_images[ $channel_id ][] = $in;
}
/**
* Create RSS 2.0 document: Add item
*
* title,description,pubDate,guid,content,category,link
*
* @access public
* @param integer Channel ID
* @param array Array of item variables
* @return void
*/
* Create RSS 2.0 document: Add item
*
* title,description,pubDate,guid,content,category,link
*
* @access public
* @param integer Channel ID
* @param array Array of item variables
* @return void
*/
public function addItemToChannel( $channel_id=0, $in=array() )
{
$this->items[ $channel_id ][] = $in;
}
/**
* Create RSS 2.0 document: Format Image
*
* @access public
* @param array Array of item variables
* @return string Image HTML
*/
* Create RSS 2.0 document: Format Image
*
* @access public
* @param array Array of item variables
* @return string Image HTML
*/
public function formatImage( $in=array() )
{
if ( ! $in['url'] )
@@ -520,24 +531,24 @@ class classRss
}
/**
* Create RSS 2.0 document: Format unixdate to rfc date
*
* @access public
* @param integer Unix timestamp
* @return string Formatted date RFC date
*/
* Create RSS 2.0 document: Format unixdate to rfc date
*
* @access public
* @param integer Unix timestamp
* @return string Formatted date RFC date
*/
public function formatDate( $time )
{
return date( 'r', $time );
}
/**
* Extract: Parse RSS document from URL
*
* @access public
* @param string URI
* @return void
*/
* Extract: Parse RSS document from URL
*
* @access public
* @param string URI
* @return void
*/
public function parseFeedFromUrl( $feed_location )
{
//-----------------------------------------
@@ -569,7 +580,6 @@ class classRss
if ( count( $this->classFileManagement->errors ) )
{
$this->errors = $this->classFileManagement->errors;
@xml_parser_free($xml_parser); // Let's kill the parser before we return
return FALSE;
}
@@ -629,12 +639,12 @@ class classRss
}
/**
* Extract: Parse RSS document from file
*
* @access public
* @param string Path
* @return void
*/
* Extract: Parse RSS document from file
*
* @access public
* @param string Path
* @return void
*/
public function parseFeedFromFile( $feed_location )
{
//-------------------------------
@@ -645,12 +655,12 @@ class classRss
}
/**
* Extract: Parse RSS document from data
*
* @access public
* @param string Raw RSS data
* @return void
*/
* Extract: Parse RSS document from data
*
* @access public
* @param string Raw RSS data
* @return void
*/
public function parseFeedFromData( $data )
{
//-------------------------------
@@ -683,14 +693,14 @@ class classRss
}
/**
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string Tag name
* @param array Attributes
* @return void
*/
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string Tag name
* @param array Attributes
* @return void
*/
private function _parseStartElement( $parser, $name, $attrs )
{
//-------------------------------
@@ -729,16 +739,21 @@ class classRss
{
$this->in_channel = 1;
}
if( array_key_exists( 'html', $attrs ) AND $attrs['html'] == 1 )
{
$this->htmlDecodingNeeded = true;
}
}
/**
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string Tag name
* @return void
*/
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string Tag name
* @return void
*/
private function _parseEndElement( $parser, $name )
{
//-------------------------------
@@ -834,8 +849,8 @@ class classRss
$this->_killElements();
$this->in_item = 0;
}
}
if ( $this->in_channel )
{
$this->in_channel--;
@@ -850,18 +865,29 @@ class classRss
{
$this->in_image--;
}
$this->htmlDecodingNeeded = false;
}
/**
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string CDATA
* @return void
*/
* Extract: Call back function for element handler
*
* @access private
* @param object Parser object
* @param string CDATA
* @return void
*/
private function _parseCharacterData( $parser, $data )
{
//-----------------------------------------
// Decode HTML if necessary
//-----------------------------------------
//if( $this->htmlDecodingNeeded )
//{
// $data = html_entity_decode( $data, ENT_QUOTES );
//}
if ( $this->in_image == 2 )
{
switch ($this->tag)
@@ -956,12 +982,12 @@ class classRss
}
/**
* Internal: Encode attribute
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
* Internal: Encode attribute
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlEncodeAttribute( $t )
{
$t = preg_replace("/&(?!#[0-9]+;)/s", '&amp;', $t );
@@ -974,12 +1000,12 @@ class classRss
}
/**
* Internal: Dencode attribute
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
* Internal: Dencode attribute
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlDecodeAttribute( $t )
{
$t = str_replace( "&amp;" , "&", $t );
@@ -992,12 +1018,12 @@ class classRss
}
/**
* Internal: Encode string
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
* Internal: Encode string
*
* @access private
* @param string Raw Text
* @return string Parsed Text
*/
private function _xmlEncodeString( $v )
{
# Fix up encoded & " ' and any other funnky IPB data
@@ -1024,12 +1050,12 @@ class classRss
}
/**
* Encode CDATA XML attribute (Make safe for transport)
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
* Encode CDATA XML attribute (Make safe for transport)
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
private function _xmlConvertSafeCdata( $v )
{
# Legacy
@@ -1044,12 +1070,12 @@ class classRss
}
/**
* Decode CDATA XML attribute (Make safe for transport)
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
* Decode CDATA XML attribute (Make safe for transport)
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
private function _xmlUnconvertSafeCdata( $v )
{
# Legacy
@@ -1064,23 +1090,23 @@ class classRss
}
/**
* Format text string
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
* Format text string
*
* @access private
* @param string Raw data
* @return string Converted Data
*/
private function _formatString( $t )
{
return trim( $t );
}
/**
* Internal: Reset arrays
*
* @access private
* @return void
*/
* Internal: Reset arrays
*
* @access private
* @return void
*/
private function _killElements()
{
$this->rss_link = "";
@@ -1094,11 +1120,11 @@ class classRss
}
/**
* Internal: Reset arrays
*
* @access private
* @return void
*/
* Internal: Reset arrays
*
* @access private
* @return void
*/
private function _killImageElements()
{
$this->rss_img_image = "";
@@ -1110,11 +1136,11 @@ class classRss
}
/**
* Internal: Reset arrays
*
* @access private
* @return void
*/
* Internal: Reset arrays
*
* @access private
* @return void
*/
private function _killChannelElements()
{
$this->rss_chan_title = "";
@@ -1123,6 +1149,4 @@ class classRss
$this->rss_chan_date = "";
}
}
?>
}
+7 -4
View File
@@ -1,17 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Wrapper for interfacing with stopforumspam.com
* Class written by Matt Mecham
* Last Updated: $Date: 2009-02-04 20:05:25 +0000 (Wed, 04 Feb 2009) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Tuesday 22nd February 2005 (16:55)
* @version $Revision: 222 $
*/
+124 -39
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Template Parser : Converts HTML "logic" into PHP code
* Last Updated: $Date: 2009-11-24 17:17:08 -0500 (Tue, 24 Nov 2009) $
* Last Updated: $Date: 2010-10-12 18:11:26 -0400 (Tue, 12 Oct 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Wednesday 23rd February 2005 13:53
* @version $Revision: 346 $
* @version $Revision: 476 $
*
* @todo [Future] Explore converting this to an XSLT parser (ala Digi)
*/
@@ -22,8 +25,8 @@ define( 'IPS_TEMPLATE_DEBUG_FILE', dirname( __FILE__ ) . '/../cache/template_deb
/**
* INTERFACE: Template plugins
* @author: Matt Mecham
* @since: IPB 3.0.0
* @author Matt Mecham
* @since IPB 3.0.0
*/
interface interfaceTemplatePlugins
@@ -172,10 +175,26 @@ class classTemplate
// INIT
//-----------------------------------------
$this->_skinGroup = preg_replace( "#^(.*)_\d+?$#", "\\1", $full_class_name );
$this->_skinGroup = preg_replace( '#^(.*)_\d+?$#', "\\1", $full_class_name );
$final_content = $this->_returnFunctionData( $data );
//-----------------------------------------
// Function Hooks
//------------------------------------------
$funcHooks = '$this->_funcHooks = array();' . "\n";
if( is_array( $this->_hookIds[ $this->_skinGroup ] ) )
{
foreach( $this->_hookIds[ $this->_skinGroup ] as $func_name => $hookIds )
{
if( is_array( $hookIds ) && count( $hookIds ) )
{
$funcHooks .= "\$this->_funcHooks['{$func_name}'] = array(".implode( ',', $hookIds ).");\n";
}
}
}
//-----------------------------------------
// Return the stuff...
//-----------------------------------------
@@ -198,6 +217,8 @@ function __construct( ipsRegistry \$registry )
\$this->memberData =& \$this->registry->member()->fetchMemberData();
\$this->cache = \$this->registry->cache();
\$this->caches =& \$this->registry->cache()->fetchCaches();
{$funcHooks}
}
EOF;
@@ -229,7 +250,7 @@ EOF;
// Remove PHP tags
//-----------------------------------------
$data = preg_replace( "#<"."\?php\n+?(.+?)\n+?\?".">#is", "\\1", $data );
$data = preg_replace( "#<".'\?php\n+?(.*)\n+?\?>#is', "\\1", $data );
//-----------------------------------------
// Pick through and get all function names
@@ -244,6 +265,7 @@ EOF;
$farray = explode( "\n", $data );
//-----------------------------------------
// Functions...
//-----------------------------------------
@@ -263,7 +285,7 @@ EOF;
$script_token = 1;
}
if ( preg_match( "/<\/script>/i", $f ) )
if ( preg_match( '/<\/script>/i', $f ) )
{
$script_token = 0;
}
@@ -274,7 +296,7 @@ EOF;
if ( $script_token == 0 )
{
if ( preg_match( "/^function\s*([\w\_]+)\s*\((.*)\)/i", $f, $matches ) )
if ( preg_match( '/^function\s*([\w\_]+)\s*\((.*)\)/i', $f, $matches ) )
{
$functions[ $matches[1] ] = '';
$config[ $matches[1] ] = $matches[2];
@@ -314,7 +336,7 @@ EOF;
}
else
{
preg_match( "/".'\$'."IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si", $ftext, $matches );
preg_match( "/".'\$'.'IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si', $ftext, $matches );
$final_content .= $this->convertHtmlToPhp( $fname, $func_data, isset( $matches[1] ) ? $matches[1] : '' );
}
@@ -384,15 +406,15 @@ EOF;
// Fix up {IPSText::xxxxx}
//-----------------------------------------
$_func_code = preg_replace( "#\{IPS(Data|ActiveMember|Member|Lib|Text)\:\:([^\}]+?)\}#", '" . ' . "IPS\\1::\\2" . ' . "', $_func_code );
$_func_code = preg_replace( "#\{\\\$this->(settings|request)->([^\}]+?)\}#" , '" . ' . "\$this->\\1->\\2" . ' . "', $_func_code );
$_func_code = preg_replace( '#\{IPS(Data|ActiveMember|Member|Lib|Text)\:\:([^\}]+?)\}#', '" . ' . "IPS\\1::\\2" . ' . "', $_func_code );
$_func_code = preg_replace( '#\{\\\$this->(settings|request)->([^\}]+?)\}#' , '" . ' . "\$this->\\1->\\2" . ' . "', $_func_code );
//-----------------------------------------
// Clear up manual escapes not in PHP blocks
// Step One
//-----------------------------------------
$_func_code = preg_replace( "#\\\{1,}\"#s", '\\"', $_func_code );
$_func_code = preg_replace( '#\\\{1,}\"#s', '\\"', $_func_code );
//-----------------------------------------
// Continue...
@@ -404,9 +426,9 @@ EOF;
$top = "/* -- {$func_name} --*/\n";
$start = "function {$func_name}($func_data) {\n\$IPBHTML = \"\";\n";
$middle = '$IPBHTML .= '.$_func_code.';';
$end = "\nreturn \$IPBHTML;\n}\n";
//-------------------------------
// Add foreach blocks...
//-------------------------------
@@ -421,8 +443,8 @@ EOF;
$end = $this->_processPluginTags( $end );
$end = preg_replace( "#\{IPS(Data|ActiveMember|Member|Lib|Text)\:\:([^\}]+?)\}#", '" . ' . "IPS\\1::\\2" . ' . "', $end );
$end = preg_replace( "#\{\\\$this->(settings|request)->([^\}]+?)\}#" , '" . ' . "\$this->\\1->\\2" . ' . "', $end );
$end = preg_replace( '#\{IPS(Data|ActiveMember|Member|Lib|Text)\:\:([^\}]+?)\}#', '" . ' . "IPS\\1::\\2" . ' . "', $end );
$end = preg_replace( '#\{\\\$this->(settings|request)->([^\}]+?)\}#' , '" . ' . "\$this->\\1->\\2" . ' . "', $end );
//----------------------------------------
// Check embedded foreach blocks
@@ -466,6 +488,54 @@ EOF;
$middle = $this->_trimEmptyIfs( $middle );
//-----------------------------------------
// Figure out if we're saving hook data
//-----------------------------------------
$functionArguments = explode( ',', $func_data );
$_funcDataNames = array();
if( is_array( $functionArguments ) )
{
foreach( $functionArguments as $r )
{
if( trim($r) )
{
/* Clean */
$r = str_replace( '$', '', trim($r) );
if( strpos( $r, '=' ) )
{
$r = substr( $r, 0, strpos( $r, '=' ) );
}
$_funcDataNames[] = trim( $r );
}
}
}
$hookPHP = '';
if( isset($this->_hookIds[ $this->_skinGroup ][ $func_name ]) AND is_array( $this->_hookIds[ $this->_skinGroup ][ $func_name ] ) )
{
$__count = '$count_'. md5( $func_name . str_replace( '.', '_', uniqid( mt_rand(), TRUE ) ) );
$hookPHP = <<<EOF
if( IPSLib::locationHasHooks( '{$this->_skinGroup}', \$this->_funcHooks['{$func_name}'] ) )
{
{$__count} = is_array(\$this->functionData['{$func_name}']) ? count(\$this->functionData['{$func_name}']) : 0;\n
EOF;
foreach( $_funcDataNames as $k => $v )
{
$hookPHP .= "\$this->functionData['{$func_name}'][{$__count}]['{$v}'] = \${$v};\n";
}
$hookPHP .= <<<EOF
}\n
EOF;
}
//-----------------------------------------
// Debug?
//-----------------------------------------
@@ -475,8 +545,8 @@ EOF;
//-------------------------------
// Return
//-------------------------------
return $top.$start.$php_tags.$middle.$end;
return $top.$start.$hookPHP.$php_tags.$middle.$end;
}
/**
@@ -611,7 +681,7 @@ EOF;
foreach( $_tmp_func_data as $_i )
{
preg_match( "#".'\$'."(\w+)(=|,|$)#i", $_i, $match );
preg_match( "#".'\$'.'(\w+)(=|,|$)#i', $_i, $match );
if( count($match) )
{
@@ -802,7 +872,7 @@ EOF;
$_normal_func_data .= ",{$keep}=''";
}
}
$block = $this->_processForeachLogic($block, $_normal_func_data, $func_name);
}
@@ -834,7 +904,7 @@ EOF;
$function_name = '__f__'. md5( $__i_count . str_replace( '.', '_', uniqid( mt_rand(), TRUE ) ) );
$php_statement = '<xxforeach_'.$function_name.'xx>$this->'.$function_name.'('.$clean_func_data.')</xxforeach_'.$function_name.'xx>';
$php_block = $this->_processHtmlLogic( addslashes($block), $func_name );
//-----------------------------------------
// PHP tags?
//-----------------------------------------
@@ -846,6 +916,7 @@ EOF;
/* Got a prefix? */
$pre_foreach_hook = '';
$post_foreach_hook = '';
if ( strstr( $statement, ':' ) )
{
list( $prefix, $statement ) = explode( ':', $statement );
@@ -858,26 +929,38 @@ EOF;
$php_block = "<!--hook.foreach.{$this->_skinGroup}.{$func_name}.{$prefix}.inner.pre-->" .
$php_block .
"<!--hook.foreach.{$this->_skinGroup}.{$func_name}.{$prefix}.inner.post-->";
$this->_hookIds[ $this->_skinGroup ][ $func_name ][] = "'{$prefix}'";
}
/* Store foreach data */
// $_tmp = explode( 'as', $statement );
// $_saveV = trim( $_tmp[0] );
$this->foreach_blocks[] = <<<EOF
function {$function_name}($normal_func_data)
{
\$_ips___x_retval = '{$pre_foreach_hook}';
\$__iteratorCount = 0;
foreach( $statement )
{
{$php_tags}
\$__iteratorCount++;
\$_ips___x_retval .= "{$php_block}\n";
}
\$_ips___x_retval .= '{$post_foreach_hook}';
unset( \$__iteratorCount );
return \$_ips___x_retval;
}
EOF;
$template = substr_replace( $template, $php_statement, $found_foreach, $found_end_foreach + strlen($tag_end_foreach) - $found_foreach);
$template = substr_replace( $template, $php_statement, $found_foreach, $found_end_foreach + strlen($tag_end_foreach) - $found_foreach);
/* Reset total length */
$total_length = strlen( $template );
$found_end_foreach = $found_foreach + strlen($php_statement) - 1;
}
return str_replace("\\'", "'", $template);
}
@@ -949,13 +1032,13 @@ EOF;
*
* Call back from the replaceRecursively function
*
* @access public, static
* @access public
* @param string Matched text string
* @param string Opening delimiter
* @param string Closing delimiter
* @return string Converted text
*/
static function _processPluginTagsCallback( $text, $textOpen, $textClose )
static public function _processPluginTagsCallback( $text, $textOpen, $textClose )
{
//-----------------------------------------
// Ok, extract options
@@ -1202,7 +1285,7 @@ EOF;
//----------------------------------------
$statement = $this->unconvertTags( substr( $template, $_start, $_end - $_start ) );
//----------------------------------------
// Not got?
//----------------------------------------
@@ -1378,7 +1461,9 @@ EOF;
$hook_pre_else = "<!--hook.if.{$this->_skinGroup}.{$func_name}.{$prefix}.pre.else-->";
$hook_post_else = "<!--hook.if.{$this->_skinGroup}.{$func_name}.{$prefix}.post.else-->";
$hook_pre_endif = "<!--hook.if.{$this->_skinGroup}.{$func_name}.{$prefix}.pre.endif-->";
$hook_post_endif = "<!--hook.if.{$this->_skinGroup}.{$func_name}.{$prefix}.post.endif-->";
$hook_post_endif = "<!--hook.if.{$this->_skinGroup}.{$func_name}.{$prefix}.post.endif-->";
$this->_hookIds[ $this->_skinGroup ][ $func_name ][] = "'{$prefix}'";
}
//----------------------------------------
@@ -1413,7 +1498,7 @@ EOF;
// Make some tags safe..
//----------------------------------------
$t = preg_replace( "/\{ipb\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
$t = preg_replace( '/\{ipb\.vars\[([\'\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)([\'\"])?\]\}/', "" , $t );
return $t;
}
@@ -1431,11 +1516,11 @@ EOF;
// Make some tags safe..
//----------------------------------------
$t = preg_replace( "/\{ips\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
$t = preg_replace( '/\{ips\.vars\[([\'\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)([\'\"])?\]\}/', "" , $t );
# IPB 2.1+ Kernel
$t = preg_replace( "/{ip(s|b|d)\.script_url}/i" , ipsRegistry::$settings['base_url'] , $t);
$t = preg_replace( "/{ip(s|b|d)\.session_id}/i" , '{$this->member->session_id }', $t);
$t = preg_replace( '/{ip(s|b|d)\.script_url}/i' , ipsRegistry::$settings['base_url'] , $t);
$t = preg_replace( '/{ip(s|b|d)\.session_id}/i' , '{$this->member->session_id }', $t);
//$t = preg_replace( "#ip(?:s|b|d)\.(member|vars|skin|lang|input)#i", '$this->ipsclass->\\1' , $t );
return $t;
@@ -1466,7 +1551,7 @@ EOF;
{
$code = $this->_trimSlashes($code);
$code = preg_replace("/".'\$'."IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si", "\\1", $code );
$code = preg_replace("/".'\$'.'IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si', "\\1", $code );
$code = trim($code);
$code = $this->_trimNewlines($code);
@@ -1497,7 +1582,7 @@ EOF;
*/
private function _trimEmptyIfs($code)
{
return preg_replace("/\"\n\s+?\"/s", "\"\"", $code );
return preg_replace('/\"\n\s+?\"/s', "\"\"", $code );
}
/**
+101 -98
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Upload handler : Handles $_FILES and checks for security
* Last Updated: $Date: 2009-02-23 17:45:20 -0500 (Mon, 23 Feb 2009) $
* Last Updated: $Date: 2010-04-14 19:25:39 -0400 (Wed, 14 Apr 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 15th March 2004
* @version $Revision: 229 $
* @version $Revision: 389 $
*
*
* Example Usage:
@@ -57,149 +60,149 @@
class classUpload
{
/**
* Name of upload form field
*
* @access public
* @var string
*/
* Name of upload form field
*
* @access public
* @var string
*/
public $upload_form_field = 'FILE_UPLOAD';
/**
* Out filename *without* extension
* (Leave blank to retain user filename)
*
* @access public
* @var string
*/
* Out filename *without* extension
* (Leave blank to retain user filename)
*
* @access public
* @var string
*/
public $out_file_name = '';
/**
* Out dir (./upload) - no trailing slash
*
* @access public
* @var string
*/
* Out dir (./upload) - no trailing slash
*
* @access public
* @var string
*/
public $out_file_dir = './';
/**
* Maximum file size of this upload
*
* @access public
* @var integer
*/
* Maximum file size of this upload
*
* @access public
* @var integer
*/
public $max_file_size = 0;
/**
* Forces PHP, CGI, etc to text
*
* @access public
* @var integer
*/
* Forces PHP, CGI, etc to text
*
* @access public
* @var integer
*/
public $make_script_safe = 1;
/**
* Force non-img file extenstion (leave blank if not) (ex: 'ibf' makes upload.doc => upload.ibf)
*
* @access public
* @var string
*/
* Force non-img file extenstion (leave blank if not) (ex: 'ibf' makes upload.doc => upload.ibf)
*
* @access public
* @var string
*/
public $force_data_ext = '';
/**
* Allowed file extensions array( 'gif', 'jpg', 'jpeg'..)
*
* @access public
* @var array
*/
* Allowed file extensions array( 'gif', 'jpg', 'jpeg'..)
*
* @access public
* @var array
*/
public $allowed_file_ext = array();
/**
* Check file extension allowed
*
* @access public
* @var boolean
*/
* Check file extension allowed
*
* @access public
* @var boolean
*/
public $check_file_ext = true;
/**
* Array of IMAGE file extensions
*
* @access public
* @var array
*/
* Array of IMAGE file extensions
*
* @access public
* @var array
*/
public $image_ext = array( 'gif', 'jpeg', 'jpg', 'jpe', 'png' );
/**
* Check to make sure an image is an image
*
* @access public
* @var boolean
*/
* Check to make sure an image is an image
*
* @access public
* @var boolean
*/
public $image_check = true;
/**
* Returns current file extension
*
* @access public
* @var string
*/
* Returns current file extension
*
* @access public
* @var string
*/
public $file_extension = '';
/**
* If force_data_ext == 1, this will return the 'real' extension
* and $file_extension will return the 'force_data_ext'
*
* @access public
* @var string
*/
* If force_data_ext == 1, this will return the 'real' extension
* and $file_extension will return the 'force_data_ext'
*
* @access public
* @var string
*/
public $real_file_extension = '';
/**
* Returns error number [1-5]
*
* @access public
* @var integer
*/
* Returns error number [1-5]
*
* @access public
* @var integer
*/
public $error_no = 0;
/**
* Returns if upload is img or not
*
* @access public
* @var boolean
*/
* Returns if upload is img or not
*
* @access public
* @var boolean
*/
public $is_image = 0;
/**
* Returns file name as was uploaded by user
*
* @access public
* @var string
*/
* Returns file name as was uploaded by user
*
* @access public
* @var string
*/
public $original_file_name = "";
/**
* Returns final file name as is saved on disk. (no path info)
*
* @access public
* @var string
*/
* Returns final file name as is saved on disk. (no path info)
*
* @access public
* @var string
*/
public $parsed_file_name = "";
/**
* Returns final file name with path info
*
* @access public
* @var string
*/
* Returns final file name with path info
*
* @access public
* @var string
*/
public $saved_upload_name = "";
/**
* Processes the upload
*
* @access public
* @return boolean Upload successful
*/
* Processes the upload
*
* @access public
* @return boolean Upload successful
*/
public function process()
{
$this->_cleanPaths();
+14 -11
View File
@@ -1,19 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* XML Handler: Rewritten for PHP5
* By Matt Mecham
* Last Updated: $Date: 2009-08-06 12:51:21 -0400 (Thu, 06 Aug 2009) $
* Last Updated: $Date: 2010-09-15 19:24:25 -0400 (Wed, 15 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 25th February 2004
* @version $Revision: 307 $
* @version $Revision: 464 $
*
*
* Example Usage:
@@ -489,7 +492,7 @@ class classXML
if ( $node->nodeType == XML_TEXT_NODE )
{
$_xmlArray = $node->nodeValue;
$_xmlArray = $this->_xmlToOutput( $node->nodeValue );
}
else if ( $node->nodeType == XML_CDATA_SECTION_NODE )
{
@@ -519,7 +522,7 @@ class classXML
{
if ( $nc->nodeName != '#text' AND $nc->nodeName != '#cdata-section' )
{
$occurance[ $nc->nodeName ]++;
$occurance[ $nc->nodeName ] = isset($occurance[ $nc->nodeName ]) ? $occurance[ $nc->nodeName ] + 1 : 1;
}
}
@@ -533,13 +536,13 @@ class classXML
$_name = '#alltext';
}
if ( $occurance[ $child->nodeName ] > 1 )
if ( isset($occurance[ $child->nodeName ]) AND $occurance[ $child->nodeName ] > 1 )
{
$_xmlArray[ $_name ][] = $this->_fetchXMLAsArray( $child, $ignoreDOMTags );
$_xmlArray[ $_name ][] = $this->_fetchXMLAsArray( $child );
}
else
{
$_xmlArray[ $_name ] = $this->_fetchXMLAsArray( $child, $ignoreDOMTags );
$_xmlArray[ $_name ] = $this->_fetchXMLAsArray( $child );
}
}
}
+44 -9
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* XML Archive Hanlder: Can create XML Archives (gzips) of multiple files, binary and ascii
* Last Updated: $Date: 2009-06-09 11:51:16 -0400 (Tue, 09 Jun 2009) $
* Last Updated: $Date: 2010-06-15 09:23:05 -0400 (Tue, 15 Jun 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 25th February 2004
* @version $Revision: 280 $
* @version $Revision: 425 $
*
*
* Example Usage:
@@ -136,8 +139,16 @@ class classXMLArchive
* @access private
* @var boolean
*/
private $_allowHiddenFiles = FALSE;
private $_allowHiddenFiles = FALSE;
/**
* Root tag values
*
* @access private
* @var array
*/
private $_defaultRootValues = array();
/**
* Constructor
*
@@ -154,9 +165,33 @@ class classXMLArchive
require_once( dirname( __FILE__ ) . '/classXML.php' );
$this->_xml = new classXML( IPS_DOC_CHAR_SET );
/* Set up the root values */
$this->_defaultRootValues = array( 'generator' => 'IPS_KERNEL', 'created' => time() );
$this->error_number = 0;
}
/**
* Adds values to the root tag
*
* @access public
* @return null
*/
public function addRootTagValues( $array=array() )
{
if ( is_array( $array ) AND count( $array ) )
{
foreach( $array as $k => $v )
{
if ( $k and $v != '' )
{
$this->_defaultRootValues[ $k ] = $v;
}
}
}
}
/**
* Allow hidden files to be added when using addDir
*
@@ -610,7 +645,7 @@ class classXMLArchive
private function _create()
{
$this->_xml->newXMLDocument();
$this->_xml->addElement( 'xmlarchive', '', array( 'generator' => 'IPS_KERNEL', 'created' => time() ) );
$this->_xml->addElement( 'xmlarchive', '', (array)$this->_defaultRootValues );
$this->_xml->addElement( 'fileset', 'xmlarchive' );
foreach( $this->_fileArray as $f )
+14 -10
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* XML-RPC Server: Send, receive and process XML-RPC requests
* Last Updated: $Date: 2009-11-24 17:17:08 -0500 (Tue, 24 Nov 2009) $
* Last Updated: $Date: 2010-07-22 04:20:19 -0400 (Thu, 22 Jul 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 6th January 2006
* @version $Revision: 346 $
* @version $Revision: 440 $
*
*
* Example Usage:
@@ -680,6 +683,7 @@ class classXmlRpc
//-------------------------------
$host = $url_parts['host'];
$_host = $url_parts['scheme'] == 'https' ? 'ssl://' . $host : $host;
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' ? 443 : 80 );
@@ -711,7 +715,7 @@ class classXmlRpc
$path .= "?" . $url_parts["query"];
}
if ( ! $fp = @fsockopen( $host, $port, $errno, $errstr, $fsocket_timeout ) )
if ( ! $fp = @fsockopen( $_host, $port, $errno, $errstr, $fsocket_timeout ) )
{
$this->errors[] = "CONNECTION REFUSED FROM {$host}";
return FALSE;
@@ -720,7 +724,7 @@ class classXmlRpc
else
{
$header = "POST $path HTTP/1.0\r\n";
$header .= "User-Agent: IPS XML-RPC Client Library (\$Revision: 346 $)\r\n";
$header .= "User-Agent: IPS XML-RPC Client Library (\$Revision: 440 $)\r\n";
$header .= "Host: $host\r\n";
if ( $this->auth_user && $this->auth_pass )
@@ -757,7 +761,7 @@ class classXmlRpc
// Strip headers
//-------------------------------
$tmp = split("\r\n\r\n", $data, 2);
$tmp = explode("\r\n\r\n", $data, 2);
$data = $tmp[1];
//-----------------------------------------
+17 -12
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* XML Handler: Can use PHP's internal XML handler, or a lite hand-rolled parser, to create and read XML files
* Last Updated: $Date: 2009-02-04 15:05:02 -0500 (Wed, 04 Feb 2009) $
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 25th February 2004
* @version $Revision: 222 $
* @version $Revision: 370 $
*
*
* Example Usage:
@@ -617,10 +620,11 @@ class class_xml
*
* Methods and functions for handling XML documents
*
* @package Invision Power Services Kernel
* @package IP.Board
* @subpackage Kernel
* @author $Author: bfarber $
* @since 25th February 2004
* @version $Revision: 222 $
* @version $Revision: 370 $
*/
class xml_lite_parse
@@ -636,8 +640,8 @@ class xml_lite_parse
/**
* Parser object
*
* @access object
* @var integer
* @access public
* @var object
*/
public $parser;
@@ -910,10 +914,11 @@ class xml_lite_parse
*
* Methods and functions for handling XML documents
*
* @package Invision Power Services Kernel
* @package IP.Board
* @subpackage Kernel
* @author $Author: bfarber $
* @since 25th February 2004
* @version $Revision: 222 $
* @version $Revision: 370 $
*/
class xml_extract
{
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+84 -51
View File
@@ -1,18 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* MySQL Database Diagnostic Methods
* Last Updated: $Date: 2009-10-09 09:24:39 -0400 (Fri, 09 Oct 2009) $
* Last Updated: $Date: 2010-10-18 16:58:05 -0400 (Mon, 18 Oct 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 15:40
* @version $Revision: 337 $
* @version $Revision: 478 $
*/
class db_tools
@@ -87,7 +90,7 @@ class db_tools
if ( preg_match( "#CREATE\s+TABLE\s+?(.+?)\s+?\(#ie", $definition, $tablename ) )
{
$tableName = $tablename[1];
//-----------------------------------------
// Does the table have a primary key?
//-----------------------------------------
@@ -138,50 +141,51 @@ class db_tools
//-----------------------------------------
// Now find all non-primary keys
//-----------------------------------------
if ( preg_match_all( "#(?<!PRIMARY)\s*?KEY\s+?(?:(\w+?)\s+?)?\((.+?)\)(\n|,\n)#is", $definition, $fields ) )
if ( preg_match_all( "#\s+?(UNIQUE KEY|KEY|INDEX|UNIQUE)\s+?(?:(\w+?)\s+?)?\(\s*(.+?)\s*\)(\n|,\n)#is", $definition, $fields ) )
{
//-----------------------------------------
// We got some fields!
//-----------------------------------------
if( count( $fields[2] ) )
{
$i = 0;
//-----------------------------------------
// Loop over the data from the preg statement
//-----------------------------------------
foreach( $fields[2] as $index_cols )
{
//-----------------------------------------
// Get index name, column name, and store
//-----------------------------------------
//$index_cols = implode( ",", array_map( 'trim', explode( ",", $this->_sqlStripTicks( preg_replace( "#\(([^\(]+?)\)#", "", $index_cols ) ) ) ) );
$index_cols = implode( ",", array_map( 'trim', explode( ",", $this->_sqlStripTicks( $index_cols ) ) ) );
$index_name = $fields[1][$i] ? $fields[1][$i] : $index_cols;
if( $index_cols != $final_primary[1] )
{
$final_keys[] = array( $index_name, $index_cols );
}
$i++;
}
}
}
if( count( $fields[3] ) )
{
$i = 0;
//-----------------------------------------
// Loop over the data from the preg statement
//-----------------------------------------
foreach( $fields[3] as $index_cols )
{
//-----------------------------------------
// Get index name, column name, and store
//-----------------------------------------
//$index_cols = implode( ",", array_map( 'trim', explode( ",", $this->_sqlStripTicks( preg_replace( "#\(([^\(]+?)\)#", "", $index_cols ) ) ) ) );
$index_cols = implode( ",", array_map( 'trim', explode( ",", $this->_sqlStripTicks( $index_cols ) ) ) );
$index_name = $fields[2][$i] ? $fields[2][$i] : $index_cols;
if( $index_cols != $final_primary[1] )
{
$final_keys[] = array( $index_name, $index_cols, in_array( strtolower($fields[1][$i]), array( 'unique key', 'unique' ) ) ? true : false );
}
$i++;
}
}
}
//-----------------------------------------
// We have some indexes for this table
//-----------------------------------------
if( $tableName AND ( $primary_key OR count($final_keys) ) )
{
{
$indexes[] = array( 'table' => $tableName,
'primary' => $final_primary,
'index' => $final_keys
'index' => $final_keys,
);
}
}
@@ -195,11 +199,11 @@ class db_tools
{
return false;
}
//-----------------------------------------
// Loop over the indexes
//-----------------------------------------
foreach( $indexes as $data )
{
//-----------------------------------------
@@ -232,14 +236,20 @@ class db_tools
// Can we find it...?
//-----------------------------------------
if ( preg_match( "#\s*PRIMARY\s+?KEY\s*(\((.+?)\))?#is", $tbl, $matches ) )
if ( preg_match( "#\s*PRIMARY\s+?KEY\s*(\(([^\)]+?)\))?#is", $tbl, $matches ) )
{
$ok = 1;
if ( $matches[2] )
{
/* strip out white space so that def: key, key matches $index_cols which is always key,key */
$matches[2] = str_replace( ' ', '', $matches[2] );
}
//-----------------------------------------
// It is...now is the index right (mulicolumn)?
//-----------------------------------------
if ( $index_cols != $matches[2] )
{
//-----------------------------------------
@@ -339,18 +349,37 @@ class db_tools
foreach( $data['index'] as $indexes )
{
$index_name = $indexes[0];
$index_cols = $indexes[1] ? $indexes[1] : $index_name;
$_checkName = $index_name;
$index_cols = str_replace( ' ', '', $indexes[1] ? $indexes[1] : $index_name );
$ok = 0;
/* MySql seems to name multi-column indexes by the first field name regardless of what KEY NAME you specify. I know, nice isn't it. */
if ( strstr( $index_cols, ',' ) AND ! preg_match( "#\n\s*?(?:UNIQUE KEY|KEY|INDEX|UNIQUE)\s+?{$_checkName}\s+?(\(\s*(.+?)\s*\))(\n|,\n)#is", $tbl, $match ) )
{
list( $_checkName, ) = explode( ',', $index_cols );
/* Now remove the xxxx(int) if it's there */
if ( strstr( $_checkName, '(' ) )
{
$_checkName = preg_replace( "#^(.*)\(([^\)]+?)\)#", "\\1", $_checkName );
}
}
//-----------------------------------------
// Is the key there?
//-----------------------------------------
if ( preg_match( "#(?<!PRIMARY)\s+?KEY\s+?{$index_name}\s+?(\((.+?)\))(\n|,\n)#is", $tbl, $match ) )
if ( preg_match( "#\n\s*?(?:UNIQUE KEY|KEY|INDEX|UNIQUE)\s+?{$_checkName}\s+?(\(\s*(.+?)\s*\))(\n|,\n)#is", $tbl, $match ) )
{
$ok = 1;
$ok = 1;
if ( $match[2] )
{
/* strip out white space so that def: key, key matches $index_cols which is always key,key */
$match[2] = str_replace( ' ', '', $match[2] );
}
//-----------------------------------------
// It is...now is the index right (mulicolumn)?
//-----------------------------------------
@@ -369,7 +398,9 @@ class db_tools
if ( strpos( $match[2], str_replace(' ', '', $mc) ) === false )
{
$query_needed = 'ALTER TABLE ' . ipsRegistry::$settings['sql_tbl_prefix'] . $data['table'] . ' DROP INDEX ' . $index_name . ', ADD INDEX ' . $index_name . ' (' . $index_cols . ')';
$_indexType = $indexes[2] ? "UNIQUE KEY" : "INDEX";
$query_needed = 'ALTER TABLE ' . ipsRegistry::$settings['sql_tbl_prefix'] . $data['table'] . ' DROP INDEX ' . $index_name . ', ADD ' . $_indexType . ' ' . $index_name . ' (' . $index_cols . ')';
//-----------------------------------------
// Are we fixing now?
@@ -402,7 +433,9 @@ class db_tools
// Generate query and set the output array
//-----------------------------------------
$query_needed = 'ALTER TABLE ' . ipsRegistry::$settings['sql_tbl_prefix'] . $data['table'] . ' ADD INDEX ' . $index_name . ' (' . $index_cols . ')';
$_indexType = $indexes[2] ? "UNIQUE KEY" : "INDEX";
$query_needed = 'ALTER TABLE ' . ipsRegistry::$settings['sql_tbl_prefix'] . $data['table'] . ' ADD ' . $_indexType . ' ' . $index_name . ' (' . $index_cols . ')';
//-----------------------------------------
// Are we fixing now?
@@ -537,7 +570,7 @@ class db_tools
// If this is a real column, map it
//-----------------------------------------
if( !in_array( $columnName, array( "PRIMARY", "KEY", "UNIQUE", "", "(", ";", ");" ) ) )
if( !in_array( $columnName, array( "PRIMARY", "KEY", "INDEX", "UNIQUE", "", "(", ";", ");" ) ) )
{
$expected_columns[] = $columnName;
$this->_mapping[ $tableName ][ $columnName ] = trim( str_replace( ',', ';', $col ) );
+207 -64
View File
@@ -1,5 +1,5 @@
<?php
// Copyright 2004-2008 Facebook. All Rights Reserved.
// Copyright 2004-2009 Facebook. All Rights Reserved.
//
// +---------------------------------------------------------------------------+
// | Facebook Platform PHP5 client |
@@ -30,13 +30,12 @@
// +---------------------------------------------------------------------------+
// | For help with this library, contact developers-help@facebook.com |
// +---------------------------------------------------------------------------+
//
include_once 'facebookapi_php5_restlib.php';
define('FACEBOOK_API_VALIDATION_ERROR', 1);
class Facebook {
public $api_client;
public $api_key;
public $secret;
public $generate_session_secret;
@@ -46,6 +45,8 @@ class Facebook {
public $user;
public $profile_user;
public $canvas_user;
public $ext_perms = array();
protected $base_domain;
/*
* Create a Facebook client like this:
@@ -65,11 +66,26 @@ class Facebook {
$this->api_key = $api_key;
$this->secret = $secret;
$this->generate_session_secret = $generate_session_secret;
$this->api_client = new FacebookRestClient($api_key, $secret);
$this->api_client = new FacebookRestClient($api_key, $secret, null);
$this->validate_fb_params();
// Set the default user id for methods that allow the caller to
// pass an explicit uid instead of using a session key.
$defaultUser = null;
if ($this->user) {
$defaultUser = $this->user;
} else if ($this->profile_user) {
$defaultUser = $this->profile_user;
} else if ($this->canvas_user) {
$defaultUser = $this->canvas_user;
}
$this->api_client->set_user($defaultUser);
if (isset($this->fb_params['friends'])) {
$this->api_client->friends_list = explode(',', $this->fb_params['friends']);
$this->api_client->friends_list =
array_filter(explode(',', $this->fb_params['friends']));
}
if (isset($this->fb_params['added'])) {
$this->api_client->added = $this->fb_params['added'];
@@ -90,17 +106,17 @@ class Facebook {
*
* For nitty-gritty details of when each of these is used, check out
* http://wiki.developers.facebook.com/index.php/Verifying_The_Signature
*
* @param bool resolve_auth_token convert an auth token into a session
*/
public function validate_fb_params($resolve_auth_token=true) {
$this->fb_params = $this->get_valid_fb_params($_POST, 48*3600, 'fb_sig');
public function validate_fb_params() {
$this->fb_params = $this->get_valid_fb_params($_POST, 48 * 3600, 'fb_sig');
// note that with preload FQL, it's possible to receive POST params in
// addition to GET, so use a different prefix to differentiate them
if (!$this->fb_params) {
$fb_params = $this->get_valid_fb_params($_GET, 48*3600, 'fb_sig');
$fb_post_params = $this->get_valid_fb_params($_POST, 48*3600, 'fb_post_sig');
$fb_params = $this->get_valid_fb_params($_GET, 48 * 3600, 'fb_sig');
$fb_post_params = $this->get_valid_fb_params($_POST,
48 * 3600, // 48 hours
'fb_post_sig');
$this->fb_params = array_merge($fb_params, $fb_post_params);
}
@@ -112,6 +128,11 @@ class Facebook {
$this->fb_params['profile_user'] : null;
$this->canvas_user = isset($this->fb_params['canvas_user']) ?
$this->fb_params['canvas_user'] : null;
$this->base_domain = isset($this->fb_params['base_domain']) ?
$this->fb_params['base_domain'] : null;
$this->ext_perms = isset($this->fb_params['ext_perms']) ?
explode(',', $this->fb_params['ext_perms'])
: array();
if (isset($this->fb_params['session_key'])) {
$session_key = $this->fb_params['session_key'];
@@ -125,12 +146,16 @@ class Facebook {
$this->set_user($user,
$session_key,
$expires);
}
// if no Facebook parameters were found in the GET or POST variables,
// then fall back to cookies, which may have cached user information
// Cookies are also used to receive session data via the Javascript API
else if ($cookies =
$this->get_valid_fb_params($_COOKIE, null, $this->api_key)) {
} else if ($cookies =
$this->get_valid_fb_params($_COOKIE, null, $this->api_key)) {
// if no Facebook parameters were found in the GET or POST variables,
// then fall back to cookies, which may have cached user information
// Cookies are also used to receive session data via the Javascript API
$base_domain_cookie = 'base_domain_' . $this->api_key;
if (isset($_COOKIE[$base_domain_cookie])) {
$this->base_domain = $_COOKIE[$base_domain_cookie];
}
// use $api_key . '_' as a prefix for the cookies in case there are
// multiple facebook clients on the same domain.
$expires = isset($cookies['expires']) ? $cookies['expires'] : null;
@@ -138,20 +163,6 @@ class Facebook {
$cookies['session_key'],
$expires);
}
// finally, if we received no parameters, but the 'auth_token' GET var
// is present, then we are in the middle of auth handshake,
// so go ahead and create the session
else if ($resolve_auth_token && isset($_GET['auth_token']) &&
$session = $this->do_get_session($_GET['auth_token'])) {
if ($this->generate_session_secret &&
!empty($session['secret'])) {
$session_secret = $session['secret'];
}
$this->set_user($session['uid'],
$session['session_key'],
$session['expires'],
isset($session_secret) ? $session_secret : null);
}
return !empty($this->fb_params);
}
@@ -186,28 +197,63 @@ class Facebook {
}
}
// Invalidate the session currently being used, and clear any state associated with it
// Invalidate the session currently being used, and clear any state associated
// with it. Note that the user will still remain logged into Facebook.
public function expire_session() {
if ($this->api_client->auth_expireSession()) {
if (!$this->in_fb_canvas() && isset($_COOKIE[$this->api_key . '_user'])) {
$cookies = array('user', 'session_key', 'expires', 'ss');
foreach ($cookies as $name) {
setcookie($this->api_key . '_' . $name, false, time() - 3600);
unset($_COOKIE[$this->api_key . '_' . $name]);
}
setcookie($this->api_key, false, time() - 3600);
unset($_COOKIE[$this->api_key]);
try {
if ($this->api_client->auth_expireSession()) {
$this->clear_cookie_state();
return true;
} else {
return false;
}
// now, clear the rest of the stored state
$this->user = 0;
$this->api_client->session_key = 0;
return true;
} else {
return false;
} catch (Exception $e) {
$this->clear_cookie_state();
}
}
/** Logs the user out of all temporary application sessions as well as their
* Facebook session. Note this will only work if the user has a valid current
* session with the application.
*
* @param string $next URL to redirect to upon logging out
*
*/
public function logout($next) {
$logout_url = $this->get_logout_url($next);
// Clear any stored state
$this->clear_cookie_state();
$this->redirect($logout_url);
}
/**
* Clears any persistent state stored about the user, including
* cookies and information related to the current session in the
* client.
*
*/
public function clear_cookie_state() {
if (!$this->in_fb_canvas() && isset($_COOKIE[$this->api_key . '_user'])) {
$cookies = array('user', 'session_key', 'expires', 'ss');
foreach ($cookies as $name) {
setcookie($this->api_key . '_' . $name,
false,
time() - 3600,
'',
$this->base_domain);
unset($_COOKIE[$this->api_key . '_' . $name]);
}
setcookie($this->api_key, false, time() - 3600, '', $this->base_domain);
unset($_COOKIE[$this->api_key]);
}
// now, clear the rest of the stored state
$this->user = 0;
$this->api_client->session_key = 0;
}
public function redirect($url) {
if ($this->in_fb_canvas()) {
echo '<fb:redirect url="' . $url . '"/>';
@@ -222,7 +268,8 @@ class Facebook {
}
public function in_frame() {
return isset($this->fb_params['in_canvas']) || isset($this->fb_params['in_iframe']);
return isset($this->fb_params['in_canvas'])
|| isset($this->fb_params['in_iframe']);
}
public function in_fb_canvas() {
return isset($this->fb_params['in_canvas']);
@@ -246,11 +293,28 @@ class Facebook {
// require_add and require_install have been removed.
// see http://developer.facebook.com/news.php?blog=1&story=116 for more details
public function require_login() {
if ($user = $this->get_loggedin_user()) {
public function require_login($required_permissions = '') {
$user = $this->get_loggedin_user();
$has_permissions = true;
if ($required_permissions) {
$this->require_frame();
$permissions = array_map('trim', explode(',', $required_permissions));
foreach ($permissions as $permission) {
if (!in_array($permission, $this->ext_perms)) {
$has_permissions = false;
break;
}
}
}
if ($user && $has_permissions) {
return $user;
}
$this->redirect($this->get_login_url(self::current_url(), $this->in_frame()));
$this->redirect(
$this->get_login_url(self::current_url(), $this->in_frame(),
$required_permissions));
}
public function require_frame() {
@@ -260,7 +324,7 @@ class Facebook {
}
public static function get_facebook_url($subdomain='www') {
return 'http://' . $subdomain . '.new.facebook.com';
return 'http://' . $subdomain . '.facebook.com';
}
public function get_install_url($next=null) {
@@ -269,14 +333,43 @@ class Facebook {
}
public function get_add_url($next=null) {
return self::get_facebook_url().'/add.php?api_key='.$this->api_key .
($next ? '&next=' . urlencode($next) : '');
$page = self::get_facebook_url().'/add.php';
$params = array('api_key' => $this->api_key);
if ($next) {
$params['next'] = $next;
}
return $page . '?' . http_build_query($params);
}
public function get_login_url($next, $canvas) {
return self::get_facebook_url().'/login.php?v=1.0&api_key=' . $this->api_key .
($next ? '&next=' . urlencode($next) : '') .
($canvas ? '&canvas' : '');
public function get_login_url($next, $canvas, $req_perms = '') {
$page = self::get_facebook_url().'/login.php';
$params = array('api_key' => $this->api_key,
'v' => '1.0',
'req_perms' => $req_perms);
if ($next) {
$params['next'] = $next;
}
if ($canvas) {
$params['canvas'] = '1';
}
return $page . '?' . http_build_query($params);
}
public function get_logout_url($next) {
$page = self::get_facebook_url().'/logout.php';
$params = array('app_key' => $this->api_key,
'session_key' => $this->api_client->session_key);
if ($next) {
$params['connect_next'] = 1;
$params['next'] = $next;
}
return $page . '?' . http_build_query($params);
}
public function set_user($user, $session_key, $expires=null, $session_secret=null) {
@@ -299,13 +392,20 @@ class Facebook {
if ($session_secret != null) {
$cookies['ss'] = $session_secret;
}
foreach ($cookies as $name => $val) {
setcookie($this->api_key . '_' . $name, $val, (int)$expires);
setcookie($this->api_key . '_' . $name, $val, (int)$expires, '', $this->base_domain);
$_COOKIE[$this->api_key . '_' . $name] = $val;
}
$sig = self::generate_sig($cookies, $this->secret);
setcookie($this->api_key, $sig, (int)$expires);
setcookie($this->api_key, $sig, (int)$expires, '', $this->base_domain);
$_COOKIE[$this->api_key] = $sig;
if ($this->base_domain != null) {
$base_domain_cookie = 'base_domain_' . $this->api_key;
setcookie($base_domain_cookie, $this->base_domain, (int)$expires, '', $this->base_domain);
$_COOKIE[$base_domain_cookie] = $this->base_domain;
}
}
/**
@@ -376,7 +476,20 @@ class Facebook {
return $fb_params;
}
/*
/**
* Validates the account that a user was trying to set up an
* independent account through Facebook Connect.
*
* @param user The user attempting to set up an independent account.
* @param hash The hash passed to the reclamation URL used.
* @return bool True if the user is the one that selected the
* reclamation link.
*/
public function verify_account_reclamation($user, $hash) {
return $hash == md5($user . $this->secret);
}
/**
* Validates that a given set of parameters match their signature.
* Parameters all match a given input prefix, such as "fb_sig".
*
@@ -388,6 +501,37 @@ class Facebook {
return self::generate_sig($fb_params, $this->secret) == $expected_sig;
}
/**
* Validate the given signed public session data structure with
* public key of the app that
* the session proof belongs to.
*
* @param $signed_data the session info that is passed by another app
* @param string $public_key Optional public key of the app. If this
* is not passed, function will make an API call to get it.
* return true if the session proof passed verification.
*/
public function verify_signed_public_session_data($signed_data,
$public_key = null) {
// If public key is not already provided, we need to get it through API
if (!$public_key) {
$public_key = $this->api_client->auth_getAppPublicKey(
$signed_data['api_key']);
}
// Create data to verify
$data_to_serialize = $signed_data;
unset($data_to_serialize['sig']);
$serialized_data = implode('_', $data_to_serialize);
// Decode signature
$signature = base64_decode($signed_data['sig']);
$result = openssl_verify($serialized_data, $signature, $public_key,
OPENSSL_ALGO_SHA1);
return $result == 1;
}
/*
* Generate a signature using the application secret key.
*
@@ -462,4 +606,3 @@ class Facebook {
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+887
View File
@@ -0,0 +1,887 @@
<?php
/**
* Patches (Matt Mecham - Invision Power Services - mmecham@invisionpower.com - May 2010)
* - added verify peer for IIS/Windows CURL
* - added non-curl fall back method in makeRequest
*/
if (!function_exists('json_decode')) {
throw new Exception('Facebook needs the JSON PHP extension.');
}
/**
* Thrown when an API call returns an exception.
*
* @author Naitik Shah <naitik@facebook.com>
*/
class FacebookApiException extends Exception
{
/**
* The result from the API server that represents the exception information.
*/
protected $result;
/**
* Make a new API Exception with the given result.
*
* @param Array $result the result from the API server
*/
public function __construct($result) {
$this->result = $result;
$code = isset($result['error_code']) ? $result['error_code'] : 0;
$msg = isset($result['error'])
? $result['error']['message'] : $result['error_msg'];
parent::__construct($msg, $code);
}
/**
* Return the associated result object returned by the API server.
*
* @returns Array the result from the API server
*/
public function getResult() {
return $this->result;
}
/**
* Returns the associated type for the error. This will default to
* 'Exception' when a type is not available.
*
* @return String
*/
public function getType() {
return
isset($this->result['error']) && isset($this->result['error']['type'])
? $this->result['error']['type']
: 'Exception';
}
/**
* To make debugging easier.
*
* @returns String the string representation of the error
*/
public function __toString() {
$str = $this->getType() . ': ';
if ($this->code != 0) {
$str .= $this->code . ': ';
}
return $str . $this->message;
}
}
/**
* Provides access to the Facebook Platform.
*
* @author Naitik Shah <naitik@facebook.com>
*/
class Facebook
{
/**
* Version.
*/
const VERSION = '2.0.3';
/**
* Default options for curl.
*/
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-2.0',
);
/**
* List of query parameters that get automatically dropped when rebuilding
* the current URL.
*/
protected static $DROP_QUERY_PARAMS = array(
'session',
);
/**
* Maps aliases to Facebook domains.
*/
public static $DOMAIN_MAP = array(
'api' => 'https://api.facebook.com/',
'api_read' => 'https://api-read.facebook.com/',
'graph' => 'https://graph.facebook.com/',
'www' => 'https://www.facebook.com/',
);
/**
* The Application ID.
*/
protected $appId;
/**
* The Application API Secret.
*/
protected $apiSecret;
/**
* The active user session, if one is available.
*/
protected $session;
/**
* Indicates that we already loaded the session as best as we could.
*/
protected $sessionLoaded = false;
/**
* Indicates if Cookie support should be enabled.
*/
protected $cookieSupport = false;
/**
* Base domain for the Cookie.
*/
protected $baseDomain = '';
/**
* Initialize a Facebook Application.
*
* The configuration:
* - appId: the application ID
* - secret: the application secret
* - cookie: (optional) boolean true to enable cookie support
* - domain: (optional) domain for the cookie
*
* @param Array $config the application configuration
*/
public function __construct($config) {
$this->setAppId($config['appId']);
$this->setApiSecret($config['secret']);
if (isset($config['cookie'])) {
$this->setCookieSupport($config['cookie']);
}
if (isset($config['domain'])) {
$this->setBaseDomain($config['domain']);
}
}
/**
* Set the Application ID.
*
* @param String $appId the Application ID
*/
public function setAppId($appId) {
$this->appId = $appId;
return $this;
}
/**
* Get the Application ID.
*
* @return String the Application ID
*/
public function getAppId() {
return $this->appId;
}
/**
* Set the API Secret.
*
* @param String $appId the API Secret
*/
public function setApiSecret($apiSecret) {
$this->apiSecret = $apiSecret;
return $this;
}
/**
* Get the API Secret.
*
* @return String the API Secret
*/
public function getApiSecret() {
return $this->apiSecret;
}
/**
* Set the Cookie Support status.
*
* @param Boolean $cookieSupport the Cookie Support status
*/
public function setCookieSupport($cookieSupport) {
$this->cookieSupport = $cookieSupport;
return $this;
}
/**
* Get the Cookie Support status.
*
* @return Boolean the Cookie Support status
*/
public function useCookieSupport() {
return $this->cookieSupport;
}
/**
* Set the base domain for the Cookie.
*
* @param String $domain the base domain
*/
public function setBaseDomain($domain) {
$this->baseDomain = $domain;
return $this;
}
/**
* Get the base domain for the Cookie.
*
* @return String the base domain
*/
public function getBaseDomain() {
return $this->baseDomain;
}
/**
* Set the Session.
*
* @param Array $session the session
* @param Boolean $write_cookie indicate if a cookie should be written. this
* value is ignored if cookie support has been disabled.
*/
public function setSession($session=null, $write_cookie=true) {
$session = $this->validateSessionObject($session);
$this->sessionLoaded = true;
$this->session = $session;
if ($write_cookie) {
$this->setCookieFromSession($session);
}
return $this;
}
/**
* Get the session object. This will automatically look for a signed session
* sent via the Cookie or Query Parameters if needed.
*
* @return Array the session
*/
public function getSession() {
if (!$this->sessionLoaded) {
$session = null;
$write_cookie = true;
// try loading session from $_REQUEST
if (isset($_REQUEST['session'])) {
$session = json_decode(
get_magic_quotes_gpc()
? stripslashes($_REQUEST['session'])
: $_REQUEST['session'],
true
);
$session = $this->validateSessionObject($session);
}
// try loading session from cookie if necessary
if (!$session && $this->useCookieSupport()) {
$cookieName = $this->getSessionCookieName();
if (isset($_COOKIE[$cookieName])) {
$session = array();
parse_str(trim(
get_magic_quotes_gpc()
? stripslashes($_COOKIE[$cookieName])
: $_COOKIE[$cookieName],
'"'
), $session);
$session = $this->validateSessionObject($session);
// write only if we need to delete a invalid session cookie
$write_cookie = empty($session);
}
}
$this->setSession($session, $write_cookie);
}
return $this->session;
}
/**
* Get the UID from the session.
*
* @return String the UID if available
*/
public function getUser() {
$session = $this->getSession();
return $session ? $session['uid'] : null;
}
/**
* Get a Login URL for use with redirects. By default, full page redirect is
* assumed. If you are using the generated URL with a window.open() call in
* JavaScript, you can pass in display=popup as part of the $params.
*
* The parameters:
* - next: the url to go to after a successful login
* - cancel_url: the url to go to after the user cancels
* - req_perms: comma separated list of requested extended perms
* - display: can be "page" (default, full page) or "popup"
*
* @param Array $params provide custom parameters
* @return String the URL for the login flow
*/
public function getLoginUrl($params=array()) {
$currentUrl = $this->getCurrentUrl();
return $this->getUrl(
'www',
'login.php',
array_merge(array(
'api_key' => $this->getAppId(),
'cancel_url' => $currentUrl,
'display' => 'page',
'fbconnect' => 1,
'next' => $currentUrl,
'return_session' => 1,
'session_version' => 3,
'v' => '1.0',
), $params)
);
}
/**
* Get a Logout URL suitable for use with redirects.
*
* The parameters:
* - next: the url to go to after a successful logout
*
* @param Array $params provide custom parameters
* @return String the URL for the logout flow
*/
public function getLogoutUrl($params=array()) {
$session = $this->getSession();
return $this->getUrl(
'www',
'logout.php',
array_merge(array(
'api_key' => $this->getAppId(),
'next' => $this->getCurrentUrl(),
'session_key' => $session['session_key'],
), $params)
);
}
/**
* Get a login status URL to fetch the status from facebook.
*
* The parameters:
* - ok_session: the URL to go to if a session is found
* - no_session: the URL to go to if the user is not connected
* - no_user: the URL to go to if the user is not signed into facebook
*
* @param Array $params provide custom parameters
* @return String the URL for the logout flow
*/
public function getLoginStatusUrl($params=array()) {
return $this->getUrl(
'www',
'extern/login_status.php',
array_merge(array(
'api_key' => $this->getAppId(),
'no_session' => $this->getCurrentUrl(),
'no_user' => $this->getCurrentUrl(),
'ok_session' => $this->getCurrentUrl(),
'session_version' => 3,
), $params)
);
}
/**
* Make an API call.
*
* @param Array $params the API call parameters
* @return the decoded response
*/
public function api(/* polymorphic */) {
$args = func_get_args();
if (is_array($args[0])) {
return $this->_restserver($args[0]);
} else {
return call_user_func_array(array($this, '_graph'), $args);
}
}
/**
* Invoke the old restserver.php endpoint.
*
* @param Array $params method call object
* @return the decoded response object
* @throws FacebookApiException
*/
protected function _restserver($params) {
// generic application level parameters
$params['api_key'] = $this->getAppId();
$params['format'] = 'json-strings';
$result = json_decode($this->_oauthRequest(
$this->getApiUrl($params['method']),
$params
), true);
// results are returned, errors are thrown
if (is_array($result) && isset($result['error_code'])) {
throw new FacebookApiException($result);
}
return $result;
}
/**
* Invoke the Graph API.
*
* @param String $path the path (required)
* @param String $method the http method (default 'GET')
* @param Array $params the query/post data
* @return the decoded response object
* @throws FacebookApiException
*/
protected function _graph($path, $method='GET', $params=array()) {
if (is_array($method) && empty($params)) {
$params = $method;
$method = 'GET';
}
$params['method'] = $method; // method override as we always do a POST
$result = json_decode($this->_oauthRequest(
$this->getUrl('graph', $path),
$params
), true);
// results are returned, errors are thrown
if (is_array($result) && isset($result['error'])) {
$e = new FacebookApiException($result);
if ($e->getType() === 'OAuthException') {
$this->setSession(null);
}
throw $e;
}
return $result;
}
/**
* Make a OAuth Request
*
* @param String $path the path (required)
* @param Array $params the query/post data
* @return the decoded response object
* @throws FacebookApiException
*/
protected function _oauthRequest($url, $params) {
if (!isset($params['access_token'])) {
$session = $this->getSession();
// either user session signed, or app signed
if ($session) {
$params['access_token'] = $session['access_token'];
} else {
$params['access_token'] = $this->getAppId() .'|'. $this->getApiSecret();
}
}
// json_encode all params values that are not strings
foreach ($params as $key => $value) {
if (!is_string($value)) {
$params[$key] = json_encode($value);
}
}
return $this->makeRequest($url, $params);
}
/**
* Makes an HTTP request. This method can be overriden by subclasses if
* developers want to do fancier things or use something other than curl to
* make the request.
*
* @param String $url the URL to make the request to
* @param Array $params the parameters to use for the POST body
* @param CurlHandler $ch optional initialized curl handle
* @return String the response text
*/
protected function makeRequest($url, $params, $ch=null) {
if ( function_exists( 'curl_init' ) AND function_exists("curl_exec") AND function_exists('curl_setopt_array') )
{
if (!$ch) {
$ch = curl_init();
}
$opts = self::$CURL_OPTS;
$opts[CURLOPT_POSTFIELDS] = $params;
$opts[CURLOPT_URL] = $url;
// stops cURL from doing a Expect: 100-continue
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if (curl_errno($ch) == 60 || curl_errno( $ch ) == 77)
{ // CURLE_SSL_CACERT
if ( defined('CA_BUNDLE_PATH') )
{
curl_setopt($ch, CURLOPT_CAINFO, CA_BUNDLE_PATH);
}
else
{
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$result = curl_exec($ch);
}
// name lookup timed out / DNS issues
else if ( curl_errno( $ch ) == 6 )
{
$url_parts = @parse_url($url);
$ip = @gethostbyname( $url_parts['host'] );
if ( $ip and preg_match( "#^\d{1,3}\.#", $ip ) )
{
// Turn of verify SSL as the IP will not match domain of cert
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url_parts['scheme'] . '://' . $ip . '/' . $url_parts['path'] );
$result = curl_exec($ch);
}
}
if ($result === false)
{
$e = new FacebookApiException(array(
'error_code' => curl_errno($ch),
'error' => array(
'message' => curl_error($ch),
'type' => 'CurlException',
),
));
curl_close($ch);
throw $e;
}
curl_close($ch);
return $result;
}
else
{
$url_parts = @parse_url($url);
$postfields = http_build_query( $params );
if ( ! $postfields )
{
$postfields = $url_parts['query'];
}
$postfields = str_replace( '&amp;', '&', $postfields );
/* Use SSL rather than https */
$url_parts['scheme'] = ( $url_parts['scheme'] == 'https' ) ? 'ssl' : $url_parts['scheme'];
$host = $url_parts['scheme'] . '://' . $url_parts['host'];
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' || $url_parts['scheme'] == 'ssl' ? 443 : 80 );
if ( !empty( $url_parts["path"] ) )
{
$path = $url_parts["path"];
}
else
{
$path = "/";
}
$header = "POST {$path} HTTP/1.0\r\n";
$header .= "Host: " . str_replace( array( 'http://', 'https://', 'ssl://' ), '', $host ) . "\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($postfields) . "\r\n\r\n";
if ( $fp = fsockopen( $host, $port, $errno, $errstr, 60 ) )
{
socket_set_timeout($fp, 60);
fwrite($fp, $header . $postfields);
while( ! feof($fp) && ! $status['timed_out'] )
{
$data .= fgets ($fp,8192);
$status = stream_get_meta_data($fp);
}
fclose($fp);
}
/* Strip headers HTTP/1.1 ### ABCD */
$httpCode = substr( $data, 9, 3 );
$lastApiCall = $url;
/* Chuncked? */
$_chunked = false;
if( preg_match( "/Transfer\-Encoding:\s*chunked/i", $data ) )
{
$_chunked = true;
}
$tmp = explode("\r\n\r\n", $data, 2);
$data = trim($tmp[1]);
if ( $_chunked )
{
$lines = explode( "\n", $data );
array_pop($lines);
array_shift($lines);
$data = implode( "\n", $lines );
}
return $data;
}
}
/**
* The name of the Cookie that contains the session.
*
* @return String the cookie name
*/
protected function getSessionCookieName() {
return 'fbs_' . $this->getAppId();
}
/**
* Set a JS Cookie based on the _passed in_ session. It does not use the
* currently stored session -- you need to explicitly pass it in.
*
* @param Array $session the session to use for setting the cookie
*/
protected function setCookieFromSession($session=null) {
if (!$this->useCookieSupport()) {
return;
}
$cookieName = $this->getSessionCookieName();
$value = 'deleted';
$expires = time() - 3600;
$domain = $this->getBaseDomain();
if ($session) {
$value = '"' . http_build_query($session, null, '&') . '"';
if (isset($session['base_domain'])) {
$domain = $session['base_domain'];
}
$expires = $session['expires'];
}
// prepend dot if a domain is found
if ($domain) {
$domain = '.' . $domain;
}
// if an existing cookie is not set, we dont need to delete it
if ($value == 'deleted' && empty($_COOKIE[$cookieName])) {
return;
}
if (headers_sent()) {
// disable error log if we are running in a CLI environment
// @codeCoverageIgnoreStart
if (php_sapi_name() != 'cli') {
error_log('Could not set cookie. Headers already sent.');
}
// @codeCoverageIgnoreEnd
// ignore for code coverage as we will never be able to setcookie in a CLI
// environment
// @codeCoverageIgnoreStart
} else {
setcookie($cookieName, $value, $expires, '/', $domain);
}
// @codeCoverageIgnoreEnd
}
/**
* Validates a session_version=3 style session object.
*
* @param Array $session the session object
* @return Array the session object if it validates, null otherwise
*/
protected function validateSessionObject($session) {
// make sure some essential fields exist
if (is_array($session) &&
isset($session['uid']) &&
isset($session['session_key']) &&
isset($session['secret']) &&
isset($session['access_token']) &&
isset($session['sig'])) {
// validate the signature
$session_without_sig = $session;
unset($session_without_sig['sig']);
$expected_sig = self::generateSignature(
$session_without_sig,
$this->getApiSecret()
);
if ($session['sig'] != $expected_sig) {
// disable error log if we are running in a CLI environment
// @codeCoverageIgnoreStart
if (php_sapi_name() != 'cli') {
error_log('Got invalid session signature in cookie.');
}
// @codeCoverageIgnoreEnd
$session = null;
}
// check expiry time
} else {
$session = null;
}
return $session;
}
/**
* Build the URL for api given parameters.
*
* @param $method String the method name.
* @return String the URL for the given parameters
*/
protected function getApiUrl($method) {
static $READ_ONLY_CALLS =
array('admin.getallocation' => 1,
'admin.getappproperties' => 1,
'admin.getbannedusers' => 1,
'admin.getlivestreamvialink' => 1,
'admin.getmetrics' => 1,
'admin.getrestrictioninfo' => 1,
'application.getpublicinfo' => 1,
'auth.getapppublickey' => 1,
'auth.getsession' => 1,
'auth.getsignedpublicsessiondata' => 1,
'comments.get' => 1,
'connect.getunconnectedfriendscount' => 1,
'dashboard.getactivity' => 1,
'dashboard.getcount' => 1,
'dashboard.getglobalnews' => 1,
'dashboard.getnews' => 1,
'dashboard.multigetcount' => 1,
'dashboard.multigetnews' => 1,
'data.getcookies' => 1,
'events.get' => 1,
'events.getmembers' => 1,
'fbml.getcustomtags' => 1,
'feed.getappfriendstories' => 1,
'feed.getregisteredtemplatebundlebyid' => 1,
'feed.getregisteredtemplatebundles' => 1,
'fql.multiquery' => 1,
'fql.query' => 1,
'friends.arefriends' => 1,
'friends.get' => 1,
'friends.getappusers' => 1,
'friends.getlists' => 1,
'friends.getmutualfriends' => 1,
'gifts.get' => 1,
'groups.get' => 1,
'groups.getmembers' => 1,
'intl.gettranslations' => 1,
'links.get' => 1,
'notes.get' => 1,
'notifications.get' => 1,
'pages.getinfo' => 1,
'pages.isadmin' => 1,
'pages.isappadded' => 1,
'pages.isfan' => 1,
'permissions.checkavailableapiaccess' => 1,
'permissions.checkgrantedapiaccess' => 1,
'photos.get' => 1,
'photos.getalbums' => 1,
'photos.gettags' => 1,
'profile.getinfo' => 1,
'profile.getinfooptions' => 1,
'stream.get' => 1,
'stream.getcomments' => 1,
'stream.getfilters' => 1,
'users.getinfo' => 1,
'users.getloggedinuser' => 1,
'users.getstandardinfo' => 1,
'users.hasapppermission' => 1,
'users.isappuser' => 1,
'users.isverified' => 1,
'video.getuploadlimits' => 1);
$name = 'api';
if (isset($READ_ONLY_CALLS[strtolower($method)])) {
$name = 'api_read';
}
return self::getUrl($name, 'restserver.php');
}
/**
* Build the URL for given domain alias, path and parameters.
*
* @param $name String the name of the domain
* @param $path String optional path (without a leading slash)
* @param $params Array optional query parameters
* @return String the URL for the given parameters
*/
protected function getUrl($name, $path='', $params=array()) {
$url = self::$DOMAIN_MAP[$name];
if ($path) {
if ($path[0] === '/') {
$path = substr($path, 1);
}
$url .= $path;
}
if ($params) {
$url .= '?' . http_build_query($params);
}
return $url;
}
/**
* Returns the Current URL, stripping it of known FB parameters that should
* not persist.
*
* @return String the current URL
*/
protected function getCurrentUrl() {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'
? 'https://'
: 'http://';
$currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$parts = parse_url($currentUrl);
// drop known fb params
$query = '';
if (!empty($parts['query'])) {
$params = array();
parse_str($parts['query'], $params);
foreach(self::$DROP_QUERY_PARAMS as $key) {
unset($params[$key]);
}
if (!empty($params)) {
$query = '?' . http_build_query($params);
}
}
// use port if non default
$port =
isset($parts['port']) &&
(($protocol === 'http://' && $parts['port'] !== 80) ||
($protocol === 'https://' && $parts['port'] !== 443))
? ':' . $parts['port'] : '';
// rebuild
return $protocol . $parts['host'] . $port . $parts['path'] . $query;
}
/**
* Generate a signature for the given params and secret.
*
* @param Array $params the parameters to sign
* @param String $secret the secret to sign with
* @return String the generated signature
*/
protected static function generateSignature($params, $secret) {
// work with sorted data
ksort($params);
// generate the base string
$base_string = '';
foreach($params as $key => $value) {
$base_string .= $key . '=' . $value;
}
$base_string .= $secret;
return md5($base_string);
}
}
@@ -0,0 +1,347 @@
<?php
/**
* Simple oAuth wrapper for Facebook
* Designed to stream line log in and token exchange
* By Matt Mecham (Invision Power Services, Inc)
* http://www.invisionpower.com
* April 2010
*
* Version 0.1
*/
class FacebookOAuth
{
/**
* Facebook Application ID
* @var int
* @access private
*/
private $_appId;
/**
* Facebook Application Secret
* @var string
* @access private
*/
private $_appSecret;
/**
* Call back URL
* URL to redirect oAuth requests to after processing at Facebook
* @var string
* @access private
*/
private $_callBackUrl;
/**
* Permissions scope
* Array containing required permissions
* @var array
* @access private
*/
private $_permsScope = array();
/**
* Form Factor
* @link http://developers.facebook.com/docs/authentication/
* @var string
* @access private
*/
private $_formFactor = '';
/**
* Last http code (200, 403, etc)
* @var string
* @access public
*/
public $httpCode;
/**
* Last API call
* @var string
* @access public
*/
public $lastApiCall;
/**
* Timeout
* @var int
* @access public
*/
public $timeout = 30;
/**
* Connect timeout
* @var int
* @access public
*/
public $connectTimeout = 30;
/**
* SSL verify peer
* @var string
* @access public
*/
public $sslVerifyPeer = FALSE;
/**
* Constant for authorize URL
*/
const AUTHORIZE_URL = 'https://graph.facebook.com/oauth/authorize';
/**
* Constant for access token
*/
const ACCESS_TOKEN_URL = 'https://graph.facebook.com/oauth/access_token';
/**
* Constructor
*
* @access public
* @param int application id
* @param string application secret
* @param string callback URL
* @param string Form factor
* @param array Array of permissions array( 'email', 'publish_stream' ), etc
*/
public function __construct( $appId, $appSecret, $callBackUrl, $permsScope, $formFactor='page' )
{
$this->_appId = $appId;
$this->_appSecret = $appSecret;
$this->setCallBackUrl( $callBackUrl );
$this->setPermissionsScope( $permsScope );
$this->setFormFactor( $formFactor );
}
/**
* Set FormFactor
* Although we require this in the contructor, the calling class may wish
* to change it to add other parameters
*
* @access public
* @param string
*/
public function setFormFactor( $formFactor )
{
if ( $formFactor )
{
$this->_formFactor = $formFactor;
}
}
/**
* Set Call back URL
* Although we require this in the contructor, the calling class may wish
* to change it to add other parameters
*
* @access public
* @param string
*/
public function setCallBackUrl( $url )
{
if ( $url )
{
$this->_callBackUrl = $url;
}
}
/**
* Set Permissions required for auth token
* Although we require this in the contructor, the calling class may wish
* to change it to add other parameters
*
* @access public
* @param string
*/
public function setPermissionsScope( $permsScope )
{
if ( is_array( $permsScope ) )
{
$this->_permsScope = $permsScope;
}
else if ( strstr( $permsScope, ',' ) )
{
$this->_permsScope = explode( ',', str_replace( ' ', '', $permsScope ) );
}
}
/**
* Get Authorize URL
* Returns a full authorize URL
*
* @access public
* @return string URL
*/
public function getAuthorizeUrl()
{
$_e = ( count( $this->_permsScope ) ) ? '&scope=' . implode( ',', $this->_permsScope ) : '';
$_f = ( $this->_formFactor ) ? '&display=' . $this->_formFactor : '';
return self::AUTHORIZE_URL . '?client_id=' . $this->_appId . '&redirect_uri=' . urlencode( $this->_callBackUrl ) . $_e . $_f;
}
/**
* Authorize
* Accepts a code, uses CURL to return a final access token
*
* @access public
* @param string Code from authorize
* @return mixed Access token or JSON error
*/
public function getAccessToken( $code )
{
$url = self::ACCESS_TOKEN_URL . '?client_id=' . $this->_appId . '&redirect_uri=' . urlencode( $this->_callBackUrl ) . '&client_secret=' . $this->_appSecret . '&code=' . rawurlencode( $code );
/* Send it and hope to receive access_token=blah */
$result = $this->_send( $url, 'GET' );
if ( preg_match( "#^access_token=(.*)$#", $result, $match ) )
{
return $match[1];
}
else
{
/* Likely to be an error in json */
return json_decode( $result );
}
}
/**
* Make an HTTP request
*
* @param private
* @param string URL
* @param string Method (post or get)
* @param array Post data to send
* @return API results
*/
private function _send($url, $method='POST', $postfields=NULL)
{
/* Compress post fields */
if ( is_array( $postfields ) AND count( $postfields ) )
{
$_postfields = $postfields;
$postfields = '';
foreach( $_postfields as $k => $v )
{
$postfields .= $k . '=' . $v . '&';
}
$postfields = trim( $postfields, '&' );
}
/* Attempt CURL */
if ( function_exists( 'curl_init' ) AND function_exists("curl_exec") )
{
$ci = curl_init();
/* Curl settings */
curl_setopt( $ci, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout );
curl_setopt( $ci, CURLOPT_TIMEOUT, $this->timeout );
curl_setopt( $ci, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt( $ci, CURLOPT_HTTPHEADER, array('Expect:') );
curl_setopt( $ci, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer );
switch ($method)
{
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if ( ! empty( $postfields) )
{
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if ( ! empty( $postfields ) )
{
$url = "{$url}?{$postfields}";
}
break;
}
curl_setopt( $ci, CURLOPT_URL, $url );
$response = curl_exec( $ci );
$this->httpCode = curl_getinfo( $ci, CURLINFO_HTTP_CODE );
$this->lastApiCall = $url;
curl_close ($ci);
if( $response )
{
return $response;
}
}
$url_parts = @parse_url($url);
if ( ! $postfields )
{
$postfields = str_replace( '&amp;', '&', $url_parts['query'] );
}
/* Use SSL rather than https */
$url_parts['scheme'] = ( $url_parts['scheme'] == 'https' ) ? 'ssl' : $url_parts['scheme'];
$host = $url_parts['scheme'] . '://' . $url_parts['host'];
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' || $url_parts['scheme'] == 'ssl' ? 443 : 80 );
if ( !empty( $url_parts["path"] ) )
{
$path = $url_parts["path"];
}
else
{
$path = "/";
}
$header = "POST {$path} HTTP/1.0\r\n";
$header .= "Host: " . str_replace( array( 'http://', 'https://', 'ssl://' ), '', $host ) . "\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($postfields) . "\r\n\r\n";
if ( $fp = fsockopen( $host, $port, $errno, $errstr, $this->timeout ) )
{
socket_set_timeout($fp, $this->timeout);
fwrite($fp, $header . $postfields);
while( ! feof($fp) && ! $status['timed_out'] )
{
$data .= fgets ($fp,8192);
$status = stream_get_meta_data($fp);
}
fclose($fp);
}
/* Strip headers HTTP/1.1 ### ABCD */
$this->httpCode = substr( $data, 9, 3 );
$this->lastApiCall = $url;
/* Chuncked? */
$_chunked = false;
if( preg_match( "/Transfer\-Encoding:\s*chunked/i", $data ) )
{
$_chunked = true;
}
$tmp = explode("\r\n\r\n", $data, 2);
$data = trim($tmp[1]);
if( $_chunked )
{
$lines = explode( "\n", $data );
array_pop($lines);
array_shift($lines);
$data = implode( "\n", $lines );
}
return $data;
}
}
+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+306 -306
View File
@@ -1,307 +1,307 @@
<?php
$PATH_TO_CLASS = dirname(ereg_replace("\\\\", "/", __FILE__)) . "/" . "ConvertTables" . "/";
define ("CONVERT_TABLES_DIR", $PATH_TO_CLASS);
define ("DEBUG_MODE", 1);
class ConvertCharset{
var $RecognizedEncoding; // (boolean) This value keeps information if string contains multibyte chars.
var $Entities; // (boolean) This value keeps information if output should be with numeric entities.
var $FromCharset; // (string) This value keeps information about source (from) encoding
var $ToCharset; // (string) This value keeps information about destination (to) encoding
var $CharsetTable; // (array) This property keeps convert Table inside
function ConvertCharset ($FromCharset, $ToCharset, $TurnOnEntities = false)
{
$this -> FromCharset = strtolower($FromCharset);
$this -> ToCharset = strtolower($ToCharset);
$this -> Entities = $TurnOnEntities;
if ($this -> FromCharset == $this -> ToCharset)
{
print $this -> DebugOutput(1, 0, $this -> FromCharset);
}
if (($this -> FromCharset == $this -> ToCharset) AND ($this -> FromCharset == "utf-8"))
{
print $this -> DebugOutput(0, 4, $this -> FromCharset);
exit;
}
if ($this -> FromCharset == "utf-8")
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> ToCharset);
}
else if ($this -> ToCharset == "utf-8")
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> FromCharset);
}
else
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> FromCharset, $this -> ToCharset);
}
}
function UnicodeEntity ($UnicodeString)
{
$OutString = "";
$StringLenght = strlen ($UnicodeString);
for ($CharPosition = 0; $CharPosition < $StringLenght; $CharPosition++)
{
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
if ($AsciiChar < 128){
$OutString .= $Char;
}
else if ($AsciiChar >> 5 == 6){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$AsciiChar = ($FirstByte * 64) + $SecondByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
else if ($AsciiChar >> 4 == 14){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$ThidrByte = ($AsciiChar & 63);
$AsciiChar = ((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
else if ($AsciiChar >> 3 == 30){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$ThidrByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$FourthByte = ($AsciiChar & 63);
$AsciiChar = ((((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte) * 64) + $FourthByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
}
return $OutString;
}
function HexToUtf ($UtfCharInHex)
{
$OutputChar = "";
$UtfCharInDec = hexdec($UtfCharInHex);
if($UtfCharInDec < 128) $OutputChar .= chr($UtfCharInDec);
else if($UtfCharInDec < 2048)$OutputChar .= chr(($UtfCharInDec >> 6) + 192) . chr(($UtfCharInDec & 63) + 128);
else if($UtfCharInDec < 65536)$OutputChar .= chr(($UtfCharInDec >> 12) + 224) . chr((($UtfCharInDec >> 6) & 63) + 128) . chr(($UtfCharInDec & 63) + 128);
else if($UtfCharInDec < 2097152)$OutputChar .= chr($UtfCharInDec >> 18 + 240) . chr((($UtfCharInDec >> 12) & 63) + 128) . chr(($UtfCharInDec >> 6) & 63 + 128) . chr($UtfCharInDec & 63 + 128);
return $OutputChar;
}
function MakeConvertTable ($FromCharset, $ToCharset = '')
{
$ConvertTable = array();
for($i = 0; $i < func_num_args(); $i++)
{
$FileName = func_get_arg($i);
if (!is_file(CONVERT_TABLES_DIR . $FileName))
{
print $this -> DebugOutput(0, 0, CONVERT_TABLES_DIR . $FileName); //Print an error message
exit;
}
$FileWithEncTabe = fopen(CONVERT_TABLES_DIR . $FileName, "r") or die(); //This die(); is just to make sure...
while(!feof($FileWithEncTabe))
{
if($OneLine = trim(fgets($FileWithEncTabe, 1024)))
{
if (substr($OneLine, 0, 1) != "#")
{
$HexValue = preg_split ("/[\s,]+/", $OneLine, 3); //We need only first 2 values
if (substr($HexValue[1], 0, 1) != "#")
{
$ArrayKey = strtoupper(str_replace(strtolower("0x"), "", $HexValue[1]));
$ArrayValue = strtoupper(str_replace(strtolower("0x"), "", $HexValue[0]));
$ConvertTable[func_get_arg($i)][$ArrayKey] = $ArrayValue;
}
} //if (substr($OneLine,...
} //if($OneLine=trim(f...
} //while(!feof($FirstFileWi...
} //for($i = 0; $i < func_...
if(!is_array($ConvertTable[$FromCharset])) $ConvertTable[$FromCharset] = array();
if ((func_num_args() > 1) && (count($ConvertTable[$FromCharset]) == count($ConvertTable[$ToCharset])) && (count(array_diff_assoc($ConvertTable[$FromCharset], $ConvertTable[$ToCharset])) == 0))
{
print $this -> DebugOutput(1, 1, "$FromCharset, $ToCharset");
}
return $ConvertTable;
}
function Convert ($StringToChange)
{
if(!strlen($StringToChange)) return '';
$StringToChange = (string)($StringToChange);
if($this -> FromCharset == $this -> ToCharset) return $StringToChange;
$NewString = "";
if ($this -> FromCharset != "utf-8")
{
for ($i = 0; $i < strlen($StringToChange); $i++)
{
$HexChar = "";
$UnicodeHexChar = "";
$HexChar = strtoupper(dechex(ord($StringToChange[$i])));
if (strlen($HexChar) == 1) $HexChar = "0" . $HexChar;
if (($this -> FromCharset == "gsm0338") && ($HexChar == '1B')){
$i++;
$HexChar .= strtoupper(dechex(ord($StringToChange[$i])));
}
if ($this -> ToCharset != "utf-8")
{
if (in_array($HexChar, $this -> CharsetTable[$this -> FromCharset]))
{
$UnicodeHexChar = array_search($HexChar, $this -> CharsetTable[$this -> FromCharset]);
$UnicodeHexChars = explode("+", $UnicodeHexChar);
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++)
{
if (array_key_exists($UnicodeHexChars[$UnicodeHexCharElement], $this -> CharsetTable[$this -> ToCharset]))
{
if ($this -> Entities == true)
{
$NewString .= $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]));
}
else
{
$NewString .= chr(hexdec($this -> CharsetTable[$this -> ToCharset][$UnicodeHexChars[$UnicodeHexCharElement]]));
}
}
else
{
print $this -> DebugOutput(0, 1, $StringToChange[$i]);
}
} //for($UnicodeH...
}
else
{
print $this -> DebugOutput(0, 2, $StringToChange[$i]);
}
}
else
{
if (in_array("$HexChar", $this -> CharsetTable[$this -> FromCharset]))
{
$UnicodeHexChar = array_search($HexChar, $this -> CharsetTable[$this -> FromCharset]);
$UnicodeHexChars = explode("+", $UnicodeHexChar);
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++)
{
if ($this -> Entities == true)
{
$NewString .= $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]));
}
else
{
$NewString .= $this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]);
}
} // for
}
else
{
print $this -> DebugOutput(0, 2, $StringToChange[$i]);
}
}
}
}
else if($this -> FromCharset == "utf-8")
{
$HexChar = "";
$UnicodeHexChar = "";
$this -> CharsetTable = $this -> MakeConvertTable ($this -> ToCharset);
foreach ($this -> CharsetTable[$this -> ToCharset] as $UnicodeHexChar => $HexChar)
{
if ($this -> Entities == true){
$EntitieOrChar = $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChar));
}
else
{
$EntitieOrChar = chr(hexdec($HexChar));
}
$StringToChange = str_replace($this -> HexToUtf($UnicodeHexChar), $EntitieOrChar, $StringToChange);
}
$NewString = $StringToChange;
}
return $NewString;
}
function ConvertArray(& $array)
{
if (!is_array($array))
{
$array = $this -> Convert($array);
return;
}
while(list($k, $v) = each($array))
{
$this -> ConvertArray($v);
$array[$k] = $v;
}
}
function DebugOutput ($Group, $Number, $Value = false)
{
$Debug[0][0] = "Error, can NOT read file: " . $Value . "<br>";
$Debug[0][1] = "Error, can't find maching char \"" . $Value . "\" in destination encoding table!" . "<br>";
$Debug[0][2] = "Error, can't find maching char \"" . $Value . "\" in source encoding table!" . "<br>";
$Debug[0][3] = "Error, you did NOT set variable " . $Value . " in Convert() function." . "<br>";
$Debug[0][4] = "You can NOT convert string from " . $Value . " to " . $Value . "!" . "<BR>";
$Debug[1][0] = "Notice, you are trying to convert string from " . $Value . " to " . $Value . ", don't you feel it's strange? ;-)" . "<br>";
$Debug[1][1] = "Notice, both charsets " . $Value . " are identical! Check encoding tables files." . "<br>";
$Debug[1][2] = "Notice, there is no unicode char in the string you are trying to convert." . "<br>";
if (DEBUG_MODE >= $Group)
{
return $Debug[$Group][$Number];
}
} // function DebugOutput
} //class ends here
<?php
$PATH_TO_CLASS = dirname(ereg_replace("\\\\", "/", __FILE__)) . "/" . "ConvertTables" . "/";
define ("CONVERT_TABLES_DIR", $PATH_TO_CLASS);
define ("DEBUG_MODE", 1);
class ConvertCharset{
var $RecognizedEncoding; // (boolean) This value keeps information if string contains multibyte chars.
var $Entities; // (boolean) This value keeps information if output should be with numeric entities.
var $FromCharset; // (string) This value keeps information about source (from) encoding
var $ToCharset; // (string) This value keeps information about destination (to) encoding
var $CharsetTable; // (array) This property keeps convert Table inside
function ConvertCharset ($FromCharset, $ToCharset, $TurnOnEntities = false)
{
$this -> FromCharset = strtolower($FromCharset);
$this -> ToCharset = strtolower($ToCharset);
$this -> Entities = $TurnOnEntities;
if ($this -> FromCharset == $this -> ToCharset)
{
print $this -> DebugOutput(1, 0, $this -> FromCharset);
}
if (($this -> FromCharset == $this -> ToCharset) AND ($this -> FromCharset == "utf-8"))
{
print $this -> DebugOutput(0, 4, $this -> FromCharset);
exit;
}
if ($this -> FromCharset == "utf-8")
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> ToCharset);
}
else if ($this -> ToCharset == "utf-8")
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> FromCharset);
}
else
{
$this -> CharsetTable = $this -> MakeConvertTable ($this -> FromCharset, $this -> ToCharset);
}
}
function UnicodeEntity ($UnicodeString)
{
$OutString = "";
$StringLenght = strlen ($UnicodeString);
for ($CharPosition = 0; $CharPosition < $StringLenght; $CharPosition++)
{
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
if ($AsciiChar < 128){
$OutString .= $Char;
}
else if ($AsciiChar >> 5 == 6){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$AsciiChar = ($FirstByte * 64) + $SecondByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
else if ($AsciiChar >> 4 == 14){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$ThidrByte = ($AsciiChar & 63);
$AsciiChar = ((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
else if ($AsciiChar >> 3 == 30){
$FirstByte = ($AsciiChar & 31);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$SecondByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$ThidrByte = ($AsciiChar & 63);
$CharPosition++;
$Char = $UnicodeString [$CharPosition];
$AsciiChar = ord ($Char);
$FourthByte = ($AsciiChar & 63);
$AsciiChar = ((((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte) * 64) + $FourthByte;
$Entity = sprintf ("&#%d;", $AsciiChar);
$OutString .= $Entity;
}
}
return $OutString;
}
function HexToUtf ($UtfCharInHex)
{
$OutputChar = "";
$UtfCharInDec = hexdec($UtfCharInHex);
if($UtfCharInDec < 128) $OutputChar .= chr($UtfCharInDec);
else if($UtfCharInDec < 2048)$OutputChar .= chr(($UtfCharInDec >> 6) + 192) . chr(($UtfCharInDec & 63) + 128);
else if($UtfCharInDec < 65536)$OutputChar .= chr(($UtfCharInDec >> 12) + 224) . chr((($UtfCharInDec >> 6) & 63) + 128) . chr(($UtfCharInDec & 63) + 128);
else if($UtfCharInDec < 2097152)$OutputChar .= chr($UtfCharInDec >> 18 + 240) . chr((($UtfCharInDec >> 12) & 63) + 128) . chr(($UtfCharInDec >> 6) & 63 + 128) . chr($UtfCharInDec & 63 + 128);
return $OutputChar;
}
function MakeConvertTable ($FromCharset, $ToCharset = '')
{
$ConvertTable = array();
for($i = 0; $i < func_num_args(); $i++)
{
$FileName = func_get_arg($i);
if (!is_file(CONVERT_TABLES_DIR . $FileName))
{
print $this -> DebugOutput(0, 0, CONVERT_TABLES_DIR . $FileName); //Print an error message
exit;
}
$FileWithEncTabe = fopen(CONVERT_TABLES_DIR . $FileName, "r") or die(); //This die(); is just to make sure...
while(!feof($FileWithEncTabe))
{
if($OneLine = trim(fgets($FileWithEncTabe, 1024)))
{
if (substr($OneLine, 0, 1) != "#")
{
$HexValue = preg_split ("/[\s,]+/", $OneLine, 3); //We need only first 2 values
if (substr($HexValue[1], 0, 1) != "#")
{
$ArrayKey = strtoupper(str_replace(strtolower("0x"), "", $HexValue[1]));
$ArrayValue = strtoupper(str_replace(strtolower("0x"), "", $HexValue[0]));
$ConvertTable[func_get_arg($i)][$ArrayKey] = $ArrayValue;
}
} //if (substr($OneLine,...
} //if($OneLine=trim(f...
} //while(!feof($FirstFileWi...
} //for($i = 0; $i < func_...
if(!is_array($ConvertTable[$FromCharset])) $ConvertTable[$FromCharset] = array();
if ((func_num_args() > 1) && (count($ConvertTable[$FromCharset]) == count($ConvertTable[$ToCharset])) && (count(array_diff_assoc($ConvertTable[$FromCharset], $ConvertTable[$ToCharset])) == 0))
{
print $this -> DebugOutput(1, 1, "$FromCharset, $ToCharset");
}
return $ConvertTable;
}
function Convert ($StringToChange)
{
if(!strlen($StringToChange)) return '';
$StringToChange = (string)($StringToChange);
if($this -> FromCharset == $this -> ToCharset) return $StringToChange;
$NewString = "";
if ($this -> FromCharset != "utf-8")
{
for ($i = 0; $i < strlen($StringToChange); $i++)
{
$HexChar = "";
$UnicodeHexChar = "";
$HexChar = strtoupper(dechex(ord($StringToChange[$i])));
if (strlen($HexChar) == 1) $HexChar = "0" . $HexChar;
if (($this -> FromCharset == "gsm0338") && ($HexChar == '1B')){
$i++;
$HexChar .= strtoupper(dechex(ord($StringToChange[$i])));
}
if ($this -> ToCharset != "utf-8")
{
if (in_array($HexChar, $this -> CharsetTable[$this -> FromCharset]))
{
$UnicodeHexChar = array_search($HexChar, $this -> CharsetTable[$this -> FromCharset]);
$UnicodeHexChars = explode("+", $UnicodeHexChar);
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++)
{
if (array_key_exists($UnicodeHexChars[$UnicodeHexCharElement], $this -> CharsetTable[$this -> ToCharset]))
{
if ($this -> Entities == true)
{
$NewString .= $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]));
}
else
{
$NewString .= chr(hexdec($this -> CharsetTable[$this -> ToCharset][$UnicodeHexChars[$UnicodeHexCharElement]]));
}
}
else
{
print $this -> DebugOutput(0, 1, $StringToChange[$i]);
}
} //for($UnicodeH...
}
else
{
print $this -> DebugOutput(0, 2, $StringToChange[$i]);
}
}
else
{
if (in_array("$HexChar", $this -> CharsetTable[$this -> FromCharset]))
{
$UnicodeHexChar = array_search($HexChar, $this -> CharsetTable[$this -> FromCharset]);
$UnicodeHexChars = explode("+", $UnicodeHexChar);
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++)
{
if ($this -> Entities == true)
{
$NewString .= $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]));
}
else
{
$NewString .= $this -> HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]);
}
} // for
}
else
{
print $this -> DebugOutput(0, 2, $StringToChange[$i]);
}
}
}
}
else if($this -> FromCharset == "utf-8")
{
$HexChar = "";
$UnicodeHexChar = "";
$this -> CharsetTable = $this -> MakeConvertTable ($this -> ToCharset);
foreach ($this -> CharsetTable[$this -> ToCharset] as $UnicodeHexChar => $HexChar)
{
if ($this -> Entities == true){
$EntitieOrChar = $this -> UnicodeEntity($this -> HexToUtf($UnicodeHexChar));
}
else
{
$EntitieOrChar = chr(hexdec($HexChar));
}
$StringToChange = str_replace($this -> HexToUtf($UnicodeHexChar), $EntitieOrChar, $StringToChange);
}
$NewString = $StringToChange;
}
return $NewString;
}
function ConvertArray(& $array)
{
if (!is_array($array))
{
$array = $this -> Convert($array);
return;
}
while(list($k, $v) = each($array))
{
$this -> ConvertArray($v);
$array[$k] = $v;
}
}
function DebugOutput ($Group, $Number, $Value = false)
{
$Debug[0][0] = "Error, can NOT read file: " . $Value . "<br>";
$Debug[0][1] = "Error, can't find maching char \"" . $Value . "\" in destination encoding table!" . "<br>";
$Debug[0][2] = "Error, can't find maching char \"" . $Value . "\" in source encoding table!" . "<br>";
$Debug[0][3] = "Error, you did NOT set variable " . $Value . " in Convert() function." . "<br>";
$Debug[0][4] = "You can NOT convert string from " . $Value . " to " . $Value . "!" . "<BR>";
$Debug[1][0] = "Notice, you are trying to convert string from " . $Value . " to " . $Value . ", don't you feel it's strange? ;-)" . "<br>";
$Debug[1][1] = "Notice, both charsets " . $Value . " are identical! Check encoding tables files." . "<br>";
$Debug[1][2] = "Notice, there is no unicode char in the string you are trying to convert." . "<br>";
if (DEBUG_MODE >= $Group)
{
return $Debug[$Group][$Number];
}
} // function DebugOutput
} //class ends here
?>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+69 -66
View File
@@ -1,67 +1,70 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2009-02-04 15:05:02 -0500 (Wed, 04 Feb 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 222 $
*
*/
interface interfaceCache
{
/**
* Disconnect from remote cache store
*
* @return boolean Disconnect successful
*/
public function disconnect();
/**
* Put data into remote cache store
*
* @param string Cache unique key
* @param string Cache value to add
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function putInCache( $key, $value, $ttl=0 );
/**
* Update value in remote cache store
*
* @param string Cache unique key
* @param string Cache value to set
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function updateInCache( $key, $value, $ttl=0 );
/**
* Retrieve a value from remote cache store
*
* @param string Cache unique key
* @return mixed Cached value
*/
public function getFromCache( $key );
/**
* Remove a value in the remote cache store
*
* @param string Cache unique key
* @return boolean Cache removal successful
*/
public function removeFromCache( $key );
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* This class acts as a cache layer, allowing you to store and retrieve data in
* external cache sources such as memcache or APC
* Last Updated: $Date: 2010-01-15 10:18:25 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 370 $
*
*/
interface interfaceCache
{
/**
* Disconnect from remote cache store
*
* @return boolean Disconnect successful
*/
public function disconnect();
/**
* Put data into remote cache store
*
* @param string Cache unique key
* @param string Cache value to add
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function putInCache( $key, $value, $ttl=0 );
/**
* Update value in remote cache store
*
* @param string Cache unique key
* @param string Cache value to set
* @param integer [Optional] Time to live
* @return boolean Cache update successful
*/
public function updateInCache( $key, $value, $ttl=0 );
/**
* Retrieve a value from remote cache store
*
* @param string Cache unique key
* @return mixed Cached value
*/
public function getFromCache( $key );
/**
* Remove a value in the remote cache store
*
* @param string Cache unique key
* @return boolean Cache removal successful
*/
public function removeFromCache( $key );
}
?>
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 1999-2005, Manuel Lemos
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 the Manuel Lemos 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.
@@ -0,0 +1,112 @@
<?php
/*
* browse_mailbox.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/browse_mailbox.php,v 1.1 2008/01/09 07:36:25 mlemos Exp $
*
*/
?><html>
<head>
<title>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</title>
</head>
<body>
<center><h1>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</h1></center>
<hr />
<?php
require('mime_parser.php');
require('rfc822_addresses.php');
require("pop3.php");
/* Uncomment when using SASL authentication mechanisms */
/*
require("sasl.php");
*/
stream_wrapper_register('pop3', 'pop3_stream'); /* Register the pop3 stream handler class */
$pop3=new pop3_class;
$pop3->hostname="localhost"; /* POP 3 server host name */
$pop3->port=110; /* POP 3 server host port,
usually 110 but some servers use other ports
Gmail uses 995 */
$pop3->tls=0; /* Establish secure connections using TLS */
$user="username"; /* Authentication user name */
$password="password"; /* Authentication password */
$pop3->realm=""; /* Authentication realm or domain */
$pop3->workstation=""; /* Workstation for NTLM authentication */
$apop=0; /* Use APOP authentication */
$pop3->authentication_mechanism="USER"; /* SASL authentication mechanism */
$pop3->debug=1; /* Output debug information */
$pop3->html_debug=1; /* Debug information is in HTML */
$pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */
if(($error=$pop3->Open())=="")
{
echo "<PRE>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
if($messages>0)
{
$pop3->GetConnectionName($connection_name);
$message=1;
$message_file='pop3://'.$connection_name.'/'.$message;
$mime=new mime_parser_class;
/*
* Set to 0 for not decoding the message bodies
*/
$mime->decode_bodies = 1;
$parameters=array(
'File'=>$message_file,
/* Read a message from a string instead of a file */
/* 'Data'=>'My message data string', */
/* Save the message body parts to a directory */
/* 'SaveBody'=>'/tmp', */
/* Do not retrieve or save message body parts */
'SkipBody'=>1,
);
$success=$mime->Decode($parameters, $decoded);
if(!$success)
echo '<h2>MIME message decoding error: '.HtmlSpecialChars($mime->error)."</h2>\n";
else
{
echo '<h2>MIME message decoding successful</h2>'."\n";
echo '<h2>Message structure</h2>'."\n";
echo '<pre>';
var_dump($decoded[0]);
echo '</pre>';
if($mime->Analyze($decoded[0], $results))
{
echo '<h2>Message analysis</h2>'."\n";
echo '<pre>';
var_dump($results);
echo '</pre>';
}
else
echo 'MIME message analyse error: '.$mime->error."\n";
}
}
if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
}
}
}
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>
</body>
</html>
+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,87 @@
<?php
/*
* parse_message.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/parse_message.php,v 1.4 2008/01/09 07:32:19 mlemos Exp $
*
*/
?><html>
<head>
<title>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</title>
</head>
<body>
<center><h1>Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes</h1></center>
<hr />
<?php
require('mime_parser.php');
require('rfc822_addresses.php');
require('pop3.php');
stream_wrapper_register('pop3', 'pop3_stream'); /* Register the pop3 stream handler class */
$user=UrlEncode("");
$password=UrlEncode("");
$realm=UrlEncode(""); /* Authentication realm or domain */
$workstation=UrlEncode(""); /* Workstation for NTLM authentication */
$apop=0; /* Use APOP authentication */
$authentication_mechanism=UrlEncode("USER"); /* SASL authentication mechanism */
$debug=1; /* Output debug information */
$html_debug=1; /* Debug information is in HTML */
$message=1;
$message_file='pop3://'.$user.':'.$password.'@localhost/'.$message.
'?debug='.$debug.'&html_debug='.$html_debug.'&realm='.$realm.'&workstation='.$workstation.
'&apop='.$apop.'&authentication_mechanism='.$authentication_mechanism;
/*
* Access Gmail POP account
*/
/*
$message_file='pop3://'.$user.':'.$password.'@pop.gmail.com:995/1?tls=1&debug=1&html_debug=1';
*/
$mime=new mime_parser_class;
/*
* Set to 0 for not decoding the message bodies
*/
$mime->decode_bodies = 1;
$parameters=array(
'File'=>$message_file,
/* Read a message from a string instead of a file */
/* 'Data'=>'My message data string', */
/* Save the message body parts to a directory */
/* 'SaveBody'=>'/tmp', */
/* Do not retrieve or save message body parts */
'SkipBody'=>1,
);
$success=$mime->Decode($parameters, $decoded);
if(!$success)
echo '<h2>MIME message decoding error: '.HtmlSpecialChars($mime->error)."</h2>\n";
else
{
echo '<h2>MIME message decoding successful</h2>'."\n";
echo '<h2>Message structure</h2>'."\n";
echo '<pre>';
var_dump($decoded[0]);
echo '</pre>';
if($mime->Analyze($decoded[0], $results))
{
echo '<h2>Message analysis</h2>'."\n";
echo '<pre>';
var_dump($results);
echo '</pre>';
}
else
echo 'MIME message analyse error: '.$mime->error."\n";
}
?>
<hr />
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+796
View File
@@ -0,0 +1,796 @@
<?php
/*
* pop3.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/pop3.php,v 1.23 2009/01/31 04:06:12 mlemos Exp $
*
*/
class pop3_class
{
var $hostname="";
var $port=110;
var $tls=0;
var $quit_handshake=1;
var $error="";
var $authentication_mechanism="USER";
var $realm="";
var $workstation="";
var $join_continuation_header_lines=1;
/* Private variables - DO NOT ACCESS */
var $connection=0;
var $state="DISCONNECTED";
var $greeting="";
var $must_update=0;
var $debug=0;
var $html_debug=0;
var $next_token="";
var $message_buffer="";
var $connection_name = '';
/* Private methods - DO NOT CALL */
Function Tokenize($string,$separator="")
{
if(!strcmp($separator,""))
{
$separator=$string;
$string=$this->next_token;
}
for($character=0;$character<strlen($separator);$character++)
{
if(GetType($position=strpos($string,$separator[$character]))=="integer")
$found=(IsSet($found) ? min($found,$position) : $position);
}
if(IsSet($found))
{
$this->next_token=substr($string,$found+1);
return(substr($string,0,$found));
}
else
{
$this->next_token="";
return($string);
}
}
Function SetError($error)
{
return($this->error=$error);
}
Function OutputDebug($message)
{
$message.="\n";
if($this->html_debug)
$message=str_replace("\n","<br />\n",HtmlSpecialChars($message));
echo $message;
flush();
}
Function GetLine()
{
for($line="";;)
{
if(feof($this->connection))
return(0);
$line.=fgets($this->connection,100);
$length=strlen($line);
if($length>=2
&& substr($line,$length-2,2)=="\r\n")
{
$line=substr($line,0,$length-2);
if($this->debug)
$this->OutputDebug("S $line");
return($line);
}
}
}
Function PutLine($line)
{
if($this->debug)
$this->OutputDebug("C $line");
return(fputs($this->connection,"$line\r\n"));
}
Function OpenConnection()
{
if($this->tls)
{
$version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7");
$php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]);
if($php_version<4003000)
return("establishing TLS connections requires at least PHP version 4.3.0");
if(!function_exists("extension_loaded")
|| !extension_loaded("openssl"))
return("establishing TLS connections requires the OpenSSL extension enabled");
}
if($this->hostname=="")
return($this->SetError("2 it was not specified a valid hostname"));
if($this->debug)
$this->OutputDebug("Connecting to ".$this->hostname." ...");
if(($this->connection=@fsockopen(($this->tls ? "tls://" : "").$this->hostname, $this->port, $error, $error_message))==0)
{
switch($error)
{
case -3:
return($this->SetError("-3 socket could not be created"));
case -4:
return($this->SetError("-4 dns lookup on hostname \"$hostname\" failed"));
case -5:
return($this->SetError("-5 connection refused or timed out"));
case -6:
return($this->SetError("-6 fdopen() call failed"));
case -7:
return($this->SetError("-7 setvbuf() call failed"));
default:
return($this->SetError($error." could not connect to the host \"".$this->hostname."\": ".$error_message));
}
}
return("");
}
Function CloseConnection()
{
if($this->debug)
$this->OutputDebug("Closing connection.");
if($this->connection!=0)
{
fclose($this->connection);
$this->connection=0;
}
}
/* Public methods */
/* Open method - set the object variable $hostname to the POP3 server address. */
Function Open()
{
if($this->state!="DISCONNECTED")
return($this->SetError("1 a connection is already opened"));
if(($error=$this->OpenConnection())!="")
return($error);
$greeting=$this->GetLine();
if(GetType($greeting)!="string"
|| $this->Tokenize($greeting," ")!="+OK")
{
$this->CloseConnection();
return($this->SetError("3 POP3 server greeting was not found"));
}
$this->Tokenize("<");
$this->greeting = $this->Tokenize(">");
$this->must_update=0;
$this->state="AUTHORIZATION";
return("");
}
/* Close method - this method must be called at least if there are any
messages to be deleted */
Function Close()
{
if($this->state=="DISCONNECTED")
return($this->SetError("no connection was opened"));
while($this->state=='GETMESSAGE')
{
if(strlen($error=$this->GetMessage(8000, $message, $end_of_message)))
return($error);
}
if($this->must_update
|| $this->quit_handshake)
{
if($this->PutLine("QUIT")==0)
return($this->SetError("Could not send the QUIT command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get quit command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not quit the connection: ".$this->Tokenize("\r\n")));
}
$this->CloseConnection();
$this->state="DISCONNECTED";
pop3_class::SetConnection(-1, $this->connection_name, $this);
return("");
}
/* Login method - pass the user name and password of POP account. Set
$apop to 1 or 0 wether you want to login using APOP method or not. */
Function Login($user,$password,$apop=0)
{
if($this->state!="AUTHORIZATION")
return($this->SetError("connection is not in AUTHORIZATION state"));
if($apop)
{
if(!strcmp($this->greeting,""))
return($this->SetError("Server does not seem to support APOP authentication"));
if($this->PutLine("APOP $user ".md5("<".$this->greeting.">".$password))==0)
return($this->SetError("Could not send the APOP command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get APOP login command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("APOP login failed: ".$this->Tokenize("\r\n")));
}
else
{
$authenticated=0;
if(strcmp($this->authentication_mechanism,"USER")
&& function_exists("class_exists")
&& class_exists("sasl_client_class"))
{
if(strlen($this->authentication_mechanism))
$mechanisms=array($this->authentication_mechanism);
else
{
$mechanisms=array();
if($this->PutLine("CAPA")==0)
return($this->SetError("Could not send the CAPA command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get CAPA command response"));
if(!strcmp($this->Tokenize($response," "),"+OK"))
{
for(;;)
{
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the supported authentication methods"));
switch($this->Tokenize($response," "))
{
case ".":
break 2;
case "SASL":
for($method=1;strlen($mechanism=$this->Tokenize(" "));$method++)
$mechanisms[]=$mechanism;
break;
}
}
}
}
$sasl=new sasl_client_class;
$sasl->SetCredential("user",$user);
$sasl->SetCredential("password",$password);
if(strlen($this->realm))
$sasl->SetCredential("realm",$this->realm);
if(strlen($this->workstation))
$sasl->SetCredential("workstation",$this->workstation);
do
{
$status=$sasl->Start($mechanisms,$message,$interactions);
}
while($status==SASL_INTERACT);
switch($status)
{
case SASL_CONTINUE:
break;
case SASL_NOMECH:
if(strlen($this->authentication_mechanism))
return($this->SetError("authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error));
break;
default:
return($this->SetError("Could not start the SASL authentication client: ".$sasl->error));
}
if(strlen($sasl->mechanism))
{
if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0)
return("Could not send the AUTH command");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get AUTH command response");
switch($this->Tokenize($response," "))
{
case "+OK":
$response="";
break;
case "+":
$response=base64_decode($this->Tokenize("\r\n"));
break;
default:
return($this->SetError("Authentication error: ".$this->Tokenize("\r\n")));
}
for(;!$authenticated;)
{
do
{
$status=$sasl->Step($response,$message,$interactions);
}
while($status==SASL_INTERACT);
switch($status)
{
case SASL_CONTINUE:
if($this->PutLine(base64_encode($message))==0)
return("Could not send message authentication step message");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get authentication step message response");
switch($this->Tokenize($response," "))
{
case "+OK":
$authenticated=1;
break;
case "+":
$response=base64_decode($this->Tokenize("\r\n"));
break;
default:
return($this->SetError("Authentication error: ".$this->Tokenize("\r\n")));
}
break;
default:
return($this->SetError("Could not process the SASL authentication step: ".$sasl->error));
}
}
}
}
if(!$authenticated)
{
if($this->PutLine("USER $user")==0)
return($this->SetError("Could not send the USER command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get user login entry response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("User error: ".$this->Tokenize("\r\n")));
if($this->PutLine("PASS $password")==0)
return($this->SetError("Could not send the PASS command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get login password entry response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Password error: ".$this->Tokenize("\r\n")));
}
}
$this->state="TRANSACTION";
return("");
}
/* Statistics method - pass references to variables to hold the number of
messages in the mail box and the size that they take in bytes. */
Function Statistics(&$messages,&$size)
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("STAT")==0)
return($this->SetError("Could not send the STAT command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get the statistics command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not get the statistics: ".$this->Tokenize("\r\n")));
$messages=$this->Tokenize(" ");
$size=$this->Tokenize(" ");
return("");
}
/* ListMessages method - the $message argument indicates the number of a
message to be listed. If you specify an empty string it will list all
messages in the mail box. The $unique_id flag indicates if you want
to list the each message unique identifier, otherwise it will
return the size of each message listed. If you list all messages the
result will be returned in an array. */
Function ListMessages($message,$unique_id)
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($unique_id)
$list_command="UIDL";
else
$list_command="LIST";
if($this->PutLine("$list_command".($message ? " ".$message : ""))==0)
return($this->SetError("Could not send the $list_command command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message list command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not get the message listing: ".$this->Tokenize("\r\n")));
if($message=="")
{
for($messages=array();;)
{
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message list response"));
if($response==".")
break;
$message=intval($this->Tokenize($response," "));
if($unique_id)
$messages[$message]=$this->Tokenize(" ");
else
$messages[$message]=intval($this->Tokenize(" "));
}
return($messages);
}
else
{
$message=intval($this->Tokenize(" "));
$value=$this->Tokenize(" ");
return($unique_id ? $value : intval($value));
}
}
/* RetrieveMessage method - the $message argument indicates the number of
a message to be listed. Pass a reference variables that will hold the
arrays of the $header and $body lines. The $lines argument tells how
many lines of the message are to be retrieved. Pass a negative number
if you want to retrieve the whole message. */
Function RetrieveMessage($message,&$headers,&$body,$lines)
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($lines<0)
{
$command="RETR";
$arguments="$message";
}
else
{
$command="TOP";
$arguments="$message $lines";
}
if($this->PutLine("$command $arguments")==0)
return($this->SetError("Could not send the $command command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message retrieval command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n")));
for($headers=$body=array(),$line=0;;)
{
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the message"));
switch($response)
{
case ".":
return("");
case "":
break 2;
default:
if(substr($response,0,1)==".")
$response=substr($response,1,strlen($response)-1);
break;
}
if($this->join_continuation_header_lines
&& $line>0
&& ($response[0]=="\t"
|| $response[0]==" "))
$headers[$line-1].=$response;
else
{
$headers[$line]=$response;
$line++;
}
}
for($line=0;;$line++)
{
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the message"));
switch($response)
{
case ".":
return("");
default:
if(substr($response,0,1)==".")
$response=substr($response,1,strlen($response)-1);
break;
}
$body[$line]=$response;
}
return("");
}
/* OpenMessage method - the $message argument indicates the number of
a message to be opened. The $lines argument tells how many lines of
the message are to be retrieved. Pass a negative number if you want
to retrieve the whole message. */
Function OpenMessage($message, $lines=-1)
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($lines<0)
{
$command="RETR";
$arguments="$message";
}
else
{
$command="TOP";
$arguments="$message $lines";
}
if($this->PutLine("$command $arguments")==0)
return($this->SetError("Could not send the $command command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message retrieval command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n")));
$this->state="GETMESSAGE";
$this->message_buffer="";
return("");
}
/* GetMessage method - the $count argument indicates the number of bytes
to be read from an opened message. The $message returns by reference
the data read from the message. The $end_of_message argument returns
by reference a boolean value indicated whether it was reached the end
of the message. */
Function GetMessage($count, &$message, &$end_of_message)
{
if($this->state!="GETMESSAGE")
return($this->SetError("connection is not in GETMESSAGE state"));
$message="";
$end_of_message=0;
while($count>strlen($this->message_buffer)
&& !$end_of_message)
{
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the message headers"));
if(!strcmp($response,"."))
{
$end_of_message=1;
$this->state="TRANSACTION";
break;
}
else
{
if(substr($response,0,1)==".")
$response=substr($response,1,strlen($response)-1);
$this->message_buffer.=$response."\r\n";
}
}
if($end_of_message
|| $count>=strlen($this->message_buffer))
{
$message=$this->message_buffer;
$this->message_buffer="";
}
else
{
$message=substr($this->message_buffer, 0, $count);
$this->message_buffer=substr($this->message_buffer, $count);
}
return("");
}
/* DeleteMessage method - the $message argument indicates the number of
a message to be marked as deleted. Messages will only be effectively
deleted upon a successful call to the Close method. */
Function DeleteMessage($message)
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("DELE $message")==0)
return($this->SetError("Could not send the DELE command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message delete command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not delete the message: ".$this->Tokenize("\r\n")));
$this->must_update=1;
return("");
}
/* ResetDeletedMessages method - Reset the list of marked to be deleted
messages. No messages will be marked to be deleted upon a successful
call to this method. */
Function ResetDeletedMessages()
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("RSET")==0)
return($this->SetError("Could not send the RSET command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get reset deleted messages command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not reset deleted messages: ".$this->Tokenize("\r\n")));
$this->must_update=0;
return("");
}
/* IssueNOOP method - Just pings the server to prevent it auto-close the
connection after an idle timeout (tipically 10 minutes). Not very
useful for most likely uses of this class. It's just here for
protocol support completeness. */
Function IssueNOOP()
{
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("NOOP")==0)
return($this->SetError("Could not send the NOOP command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not NOOP command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not issue the NOOP command: ".$this->Tokenize("\r\n")));
return("");
}
Function &SetConnection($set, &$current_name, &$pop3)
{
static $connections = array();
if($set>0)
{
$current_name = strval(count($connections));
$connections[$current_name] = &$pop3;
}
elseif($set<0)
{
$connections[$current_name] = '';
$current_name = '';
}
elseif(IsSet($connections[$current_name])
&& GetType($connections[$current_name])!='string')
{
$connection = &$connections[$current_name];
return($connection);
}
return($pop3);
}
/* GetConnectionName method - Retrieve the name associated to an
established POP3 server connection to use as virtual host name for
use in POP3 stream wrapper URLs. */
Function GetConnectionName(&$connection_name)
{
if($this->state!="TRANSACTION")
return($this->SetError("cannot get the name of a POP3 connection that was not established and the user has logged in"));
if(strlen($this->connection_name) == 0)
pop3_class::SetConnection(1, $this->connection_name, $this);
$connection_name = $this->connection_name;
return('');
}
};
class pop3_stream
{
var $opened = 0;
var $report_errors = 1;
var $read = 0;
var $buffer = "";
var $end_of_message=1;
var $previous_connection = 0;
var $pop3;
Function SetError($error)
{
if($this->report_errors)
trigger_error($error);
return(FALSE);
}
Function ParsePath($path, &$url)
{
if(!$this->previous_connection)
{
if(IsSet($url["host"]))
$this->pop3->hostname=$url["host"];
if(IsSet($url["port"]))
$this->pop3->port=intval($url["port"]);
if(IsSet($url["scheme"])
&& !strcmp($url["scheme"],"pop3s"))
$this->pop3->tls=1;
if(!IsSet($url["user"]))
return($this->SetError("it was not specified a valid POP3 user"));
if(!IsSet($url["pass"]))
return($this->SetError("it was not specified a valid POP3 password"));
if(!IsSet($url["path"]))
return($this->SetError("it was not specified a valid mailbox path"));
}
if(IsSet($url["query"]))
{
parse_str($url["query"],$query);
if(IsSet($query["debug"]))
$this->pop3->debug = intval($query["debug"]);
if(IsSet($query["html_debug"]))
$this->pop3->html_debug = intval($query["html_debug"]);
if(!$this->previous_connection)
{
if(IsSet($query["tls"]))
$this->pop3->tls = intval($query["tls"]);
if(IsSet($query["realm"]))
$this->pop3->realm = UrlDecode($query["realm"]);
if(IsSet($query["workstation"]))
$this->pop3->workstation = UrlDecode($query["workstation"]);
if(IsSet($query["authentication_mechanism"]))
$this->pop3->realm = UrlDecode($query["authentication_mechanism"]);
}
if(IsSet($query["quit_handshake"]))
$this->pop3->quit_handshake = intval($query["quit_handshake"]);
}
return(TRUE);
}
Function stream_open($path, $mode, $options, &$opened_path)
{
$this->report_errors = (($options & STREAM_REPORT_ERRORS) !=0);
if(strcmp($mode, "r"))
return($this->SetError("the message can only be opened for reading"));
$url=parse_url($path);
$host = $url['host'];
$pop3 = &pop3_class::SetConnection(0, $host, $this->pop3);
if(IsSet($pop3))
{
$this->pop3 = &$pop3;
$this->previous_connection = 1;
}
else
$this->pop3=new pop3_class;
if(!$this->ParsePath($path, $url))
return(FALSE);
$message=substr($url["path"],1);
if(strcmp(intval($message), $message)
|| $message<=0)
return($this->SetError("it was not specified a valid message to retrieve"));
if(!$this->previous_connection)
{
if(strlen($error=$this->pop3->Open()))
return($this->SetError($error));
$this->opened = 1;
$apop = (IsSet($url["query"]["apop"]) ? intval($url["query"]["apop"]) : 0);
if(strlen($error=$this->pop3->Login(UrlDecode($url["user"]), UrlDecode($url["pass"]),$apop)))
{
$this->stream_close();
return($this->SetError($error));
}
}
if(strlen($error=$this->pop3->OpenMessage($message,-1)))
{
$this->stream_close();
return($this->SetError($error));
}
$this->end_of_message=FALSE;
if($options & STREAM_USE_PATH)
$opened_path=$path;
$this->read = 0;
$this->buffer = "";
return(TRUE);
}
Function stream_eof()
{
if($this->read==0)
return(FALSE);
return($this->end_of_message);
}
Function stream_read($count)
{
if($count<=0)
return($this->SetError("it was not specified a valid length of the message to read"));
if($this->end_of_message)
return("");
if(strlen($error=$this->pop3->GetMessage($count, $read, $this->end_of_message)))
return($this->SetError($error));
$this->read += strlen($read);
return($read);
}
Function stream_close()
{
while(!$this->end_of_message)
$this->stream_read(8000);
if($this->opened)
{
$this->pop3->Close();
$this->opened = 0;
}
}
};
?>
+97
View File
@@ -0,0 +1,97 @@
<?php
/*
* test_pop3.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/test_pop3.php,v 1.7 2006/06/11 14:52:09 mlemos Exp $
*
*/
?><HTML>
<HEAD>
<TITLE>Test for Manuel Lemos's PHP POP3 class</TITLE>
</HEAD>
<BODY>
<?php
require("pop3.php");
/* Uncomment when using SASL authentication mechanisms */
/*
require("sasl.php");
*/
$pop3=new pop3_class;
$pop3->hostname="localhost"; /* POP 3 server host name */
$pop3->port=110; /* POP 3 server host port,
usually 110 but some servers use other ports
Gmail uses 995 */
$pop3->tls=0; /* Establish secure connections using TLS */
$user="username"; /* Authentication user name */
$password="password"; /* Authentication password */
$pop3->realm=""; /* Authentication realm or domain */
$pop3->workstation=""; /* Workstation for NTLM authentication */
$apop=0; /* Use APOP authentication */
$pop3->authentication_mechanism="USER"; /* SASL authentication mechanism */
$pop3->debug=1; /* Output debug information */
$pop3->html_debug=1; /* Debug information is in HTML */
$pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */
if(($error=$pop3->Open())=="")
{
echo "<PRE>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
$result=$pop3->ListMessages("",0);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result)," - ",$result[Key($result)]," bytes.</PRE>\n";
$result=$pop3->ListMessages("",1);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result),", Unique ID - \"",$result[Key($result)],"\"</PRE>\n";
if($messages>0)
{
if(($error=$pop3->RetrieveMessage(1,$headers,$body,2))=="")
{
echo "<PRE>Message 1:\n---Message headers starts below---</PRE>\n";
for($line=0;$line<count($headers);$line++)
echo "<PRE>",HtmlSpecialChars($headers[$line]),"</PRE>\n";
echo "<PRE>---Message headers ends above---\n---Message body starts below---</PRE>\n";
for($line=0;$line<count($body);$line++)
echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
echo "<PRE>---Message body ends above---</PRE>\n";
if(($error=$pop3->DeleteMessage(1))=="")
{
echo "<PRE>Marked message 1 for deletion.</PRE>\n";
if(($error=$pop3->ResetDeletedMessages())=="")
{
echo "<PRE>Resetted the list of messages to be deleted.</PRE>\n";
}
}
}
}
if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
}
else
$error=$result;
}
else
$error=$result;
}
}
}
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>
</BODY>
</HTML>
+22
View File
@@ -0,0 +1,22 @@
Copyright (c) 2009 Abraham Williams - http://abrah.am - abraham@poseurte.ch
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+777
View File
@@ -0,0 +1,777 @@
<?php
// vim: foldmethod=marker
if ( ! @extension_loaded('OAuth') )
{
class OAuthException extends Exception {
// pass
}
}
class OAuthConsumer {
public $key;
public $secret;
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
function __toString() {
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
}
}
class OAuthToken {
// access tokens and request tokens
public $key;
public $secret;
/**
* key = the token
* secret = the token secret
*/
function __construct($key, $secret) {
$this->key = $key;
$this->secret = $secret;
}
/**
* generates the basic string serialization of a token that a server
* would respond to request_token and access_token calls with
*/
function to_string() {
return "oauth_token=" .
OAuthUtil::urlencode_rfc3986($this->key) .
"&oauth_token_secret=" .
OAuthUtil::urlencode_rfc3986($this->secret);
}
function __toString() {
return $this->to_string();
}
}
class OAuthSignatureMethod {
public function check_signature(&$request, $consumer, $token, $signature) {
$built = $this->build_signature($request, $consumer, $token);
return $built == $signature;
}
}
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
function get_name() {
return "HMAC-SHA1";
}
public function build_signature($request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
($token) ? $token->secret : ""
);
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
}
}
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
public function get_name() {
return "PLAINTEXT";
}
public function build_signature($request, $consumer, $token) {
$sig = array(
OAuthUtil::urlencode_rfc3986($consumer->secret)
);
if ($token) {
array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
} else {
array_push($sig, '');
}
$raw = implode("&", $sig);
// for debug purposes
$request->base_string = $raw;
return OAuthUtil::urlencode_rfc3986($raw);
}
}
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
public function get_name() {
return "RSA-SHA1";
}
protected function fetch_public_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
// (2) fetch via http using a url provided by the requester
// (3) some sort of specific discovery code based on request
//
// either way should return a string representation of the certificate
throw Exception("fetch_public_cert not implemented");
}
protected function fetch_private_cert(&$request) {
// not implemented yet, ideas are:
// (1) do a lookup in a table of trusted certs keyed off of consumer
//
// either way should return a string representation of the certificate
throw Exception("fetch_private_cert not implemented");
}
public function build_signature(&$request, $consumer, $token) {
$base_string = $request->get_signature_base_string();
$request->base_string = $base_string;
// Fetch the private key cert based on the request
$cert = $this->fetch_private_cert($request);
// Pull the private key ID from the certificate
$privatekeyid = openssl_get_privatekey($cert);
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
return base64_encode($signature);
}
public function check_signature(&$request, $consumer, $token, $signature) {
$decoded_sig = base64_decode($signature);
$base_string = $request->get_signature_base_string();
// Fetch the public key cert based on the request
$cert = $this->fetch_public_cert($request);
// Pull the public key ID from the certificate
$publickeyid = openssl_get_publickey($cert);
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
return $ok == 1;
}
}
class OAuthRequest {
private $parameters;
private $http_method;
private $http_url;
// for debug purposes
public $base_string;
public static $version = '1.0a';
public static $POST_INPUT = 'php://input';
function __construct($http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$this->parameters = $parameters;
$this->http_method = $http_method;
$this->http_url = $http_url;
}
/**
* attempt to build up a request from what was passed to the server
*/
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
? 'http'
: 'https';
@$http_url or $http_url = $scheme .
'://' . $_SERVER['HTTP_HOST'] .
':' .
$_SERVER['SERVER_PORT'] .
$_SERVER['REQUEST_URI'];
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
// We weren't handed any parameters, so let's find the ones relevant to
// this request.
// If you run XML-RPC or similar you should use this to provide your own
// parsed parameter-list
if (!$parameters) {
// Find request headers
$request_headers = OAuthUtil::get_headers();
// Parse the query-string to find GET parameters
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
// It's a POST request of the proper content-type, so parse POST
// parameters and add those overriding any duplicates from GET
if ($http_method == "POST"
&& @strstr($request_headers["Content-Type"],
"application/x-www-form-urlencoded")
) {
$post_data = OAuthUtil::parse_parameters(
file_get_contents(self::$POST_INPUT)
);
$parameters = array_merge($parameters, $post_data);
}
// We have a Authorization-header with OAuth data. Parse the header
// and add those overriding any duplicates from GET or POST
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
$header_parameters = OAuthUtil::split_header(
$request_headers['Authorization']
);
$parameters = array_merge($parameters, $header_parameters);
}
}
return new OAuthRequest($http_method, $http_url, $parameters);
}
/**
* pretty much a helper function to set up the request
*/
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
@$parameters or $parameters = array();
$defaults = array("oauth_version" => OAuthRequest::$version,
"oauth_nonce" => OAuthRequest::generate_nonce(),
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
"oauth_consumer_key" => $consumer->key);
if ($token)
$defaults['oauth_token'] = $token->key;
$parameters = array_merge($defaults, $parameters);
return new OAuthRequest($http_method, $http_url, $parameters);
}
public function set_parameter($name, $value, $allow_duplicates = true) {
if ($allow_duplicates && isset($this->parameters[$name])) {
// We have already added parameter(s) with this name, so add to the list
if (is_scalar($this->parameters[$name])) {
// This is the first duplicate, so transform scalar (string)
// into an array so we can add the duplicates
$this->parameters[$name] = array($this->parameters[$name]);
}
$this->parameters[$name][] = $value;
} else {
$this->parameters[$name] = $value;
}
}
public function get_parameter($name) {
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
}
public function get_parameters() {
return $this->parameters;
}
public function unset_parameter($name) {
unset($this->parameters[$name]);
}
/**
* The request parameters, sorted and concatenated into a normalized string.
* @return string
*/
public function get_signable_parameters() {
// Grab all parameters
$params = $this->parameters;
// Remove oauth_signature if present
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
if (isset($params['oauth_signature'])) {
unset($params['oauth_signature']);
}
return OAuthUtil::build_http_query($params);
}
/**
* Returns the base string of this request
*
* The base string defined as the method, the url
* and the parameters (normalized), each urlencoded
* and the concated with &.
*/
public function get_signature_base_string() {
$parts = array(
$this->get_normalized_http_method(),
$this->get_normalized_http_url(),
$this->get_signable_parameters()
);
$parts = OAuthUtil::urlencode_rfc3986($parts);
return implode('&', $parts);
}
/**
* just uppercases the http method
*/
public function get_normalized_http_method() {
return strtoupper($this->http_method);
}
/**
* parses the url and rebuilds it to be
* scheme://host/path
*/
public function get_normalized_http_url() {
$parts = parse_url($this->http_url);
$port = @$parts['port'];
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];
$port or $port = ($scheme == 'https') ? '443' : '80';
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
return "$scheme://$host$path";
}
/**
* builds a url usable for a GET request
*/
public function to_url() {
$post_data = $this->to_postdata();
$out = $this->get_normalized_http_url();
if ($post_data) {
$out .= '?'.$post_data;
}
return $out;
}
/**
* builds the data one would send in a POST request
*/
public function to_postdata() {
return OAuthUtil::build_http_query($this->parameters);
}
/**
* builds the Authorization: header
*/
public function to_header() {
$out ='Authorization: OAuth realm=""';
$total = array();
foreach ($this->parameters as $k => $v) {
if (substr($k, 0, 5) != "oauth") continue;
if (is_array($v)) {
throw new OAuthException('Arrays not supported in headers');
}
$out .= ',' .
OAuthUtil::urlencode_rfc3986($k) .
'="' .
OAuthUtil::urlencode_rfc3986($v) .
'"';
}
return $out;
}
public function __toString() {
return $this->to_url();
}
public function sign_request($signature_method, $consumer, $token) {
$this->set_parameter(
"oauth_signature_method",
$signature_method->get_name(),
false
);
$signature = $this->build_signature($signature_method, $consumer, $token);
$this->set_parameter("oauth_signature", $signature, false);
}
public function build_signature($signature_method, $consumer, $token) {
$signature = $signature_method->build_signature($this, $consumer, $token);
return $signature;
}
/**
* util function: current timestamp
*/
private static function generate_timestamp() {
return time();
}
/**
* util function: current nonce
*/
private static function generate_nonce() {
$mt = microtime();
$rand = mt_rand();
return md5($mt . $rand); // md5s look nicer than numbers
}
}
class OAuthServer {
protected $timestamp_threshold = 300; // in seconds, five minutes
protected $version = 1.0; // hi blaine
protected $signature_methods = array();
protected $data_store;
function __construct($data_store) {
$this->data_store = $data_store;
}
public function add_signature_method($signature_method) {
$this->signature_methods[$signature_method->get_name()] =
$signature_method;
}
// high level functions
/**
* process a request_token request
* returns the request token on success
*/
public function fetch_request_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// no token required for the initial token request
$token = NULL;
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_request_token($consumer);
return $new_token;
}
/**
* process an access_token request
* returns the access token on success
*/
public function fetch_access_token(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
// requires authorized request token
$token = $this->get_token($request, $consumer, "request");
$this->check_signature($request, $consumer, $token);
$new_token = $this->data_store->new_access_token($token, $consumer);
return $new_token;
}
/**
* verify an api call, checks all the parameters
*/
public function verify_request(&$request) {
$this->get_version($request);
$consumer = $this->get_consumer($request);
$token = $this->get_token($request, $consumer, "access");
$this->check_signature($request, $consumer, $token);
return array($consumer, $token);
}
// Internals from here
/**
* version 1
*/
private function get_version(&$request) {
$version = $request->get_parameter("oauth_version");
if (!$version) {
$version = 1.0;
}
if ($version && $version != $this->version) {
throw new OAuthException("OAuth version '$version' not supported");
}
return $version;
}
/**
* figure out the signature with some defaults
*/
private function get_signature_method(&$request) {
$signature_method =
@$request->get_parameter("oauth_signature_method");
if (!$signature_method) {
$signature_method = "PLAINTEXT";
}
if (!in_array($signature_method,
array_keys($this->signature_methods))) {
throw new OAuthException(
"Signature method '$signature_method' not supported " .
"try one of the following: " .
implode(", ", array_keys($this->signature_methods))
);
}
return $this->signature_methods[$signature_method];
}
/**
* try to find the consumer for the provided request's consumer key
*/
private function get_consumer(&$request) {
$consumer_key = @$request->get_parameter("oauth_consumer_key");
if (!$consumer_key) {
throw new OAuthException("Invalid consumer key");
}
$consumer = $this->data_store->lookup_consumer($consumer_key);
if (!$consumer) {
throw new OAuthException("Invalid consumer");
}
return $consumer;
}
/**
* try to find the token for the provided request's token key
*/
private function get_token(&$request, $consumer, $token_type="access") {
$token_field = @$request->get_parameter('oauth_token');
$token = $this->data_store->lookup_token(
$consumer, $token_type, $token_field
);
if (!$token) {
throw new OAuthException("Invalid $token_type token: $token_field");
}
return $token;
}
/**
* all-in-one function to check the signature on a request
* should guess the signature method appropriately
*/
private function check_signature(&$request, $consumer, $token) {
// this should probably be in a different method
$timestamp = @$request->get_parameter('oauth_timestamp');
$nonce = @$request->get_parameter('oauth_nonce');
$this->check_timestamp($timestamp);
$this->check_nonce($consumer, $token, $nonce, $timestamp);
$signature_method = $this->get_signature_method($request);
$signature = $request->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature(
$request,
$consumer,
$token,
$signature
);
if (!$valid_sig) {
throw new OAuthException("Invalid signature");
}
}
/**
* check that the timestamp is new enough
*/
private function check_timestamp($timestamp) {
// verify that timestamp is recentish
$now = time();
if ($now - $timestamp > $this->timestamp_threshold) {
throw new OAuthException(
"Expired timestamp, yours $timestamp, ours $now"
);
}
}
/**
* check that the nonce is not repeated
*/
private function check_nonce($consumer, $token, $nonce, $timestamp) {
// verify that the nonce is uniqueish
$found = $this->data_store->lookup_nonce(
$consumer,
$token,
$nonce,
$timestamp
);
if ($found) {
throw new OAuthException("Nonce already used: $nonce");
}
}
}
class OAuthDataStore {
function lookup_consumer($consumer_key) {
// implement me
}
function lookup_token($consumer, $token_type, $token) {
// implement me
}
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
// implement me
}
function new_request_token($consumer) {
// return a new token attached to this consumer
}
function new_access_token($token, $consumer) {
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
}
}
class OAuthUtil {
public static function urlencode_rfc3986($input) {
if (is_array($input)) {
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
} else if (is_scalar($input)) {
return str_replace(
'+',
' ',
str_replace('%7E', '~', rawurlencode($input))
);
} else {
return '';
}
}
// This decode function isn't taking into consideration the above
// modifications to the encoding process. However, this method doesn't
// seem to be used anywhere so leaving it as is.
public static function urldecode_rfc3986($string) {
return urldecode($string);
}
// Utility function for turning the Authorization: header into
// parameters, has to do some unescaping
// Can filter out any non-oauth parameters if needed (default behaviour)
public static function split_header($header, $only_allow_oauth_parameters = true) {
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
}
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
// helper to try to sort out headers for people who aren't running apache
public static function get_headers() {
if (function_exists('apache_request_headers')) {
// we need this to get the actual Authorization: header
// because apache tends to tell us it doesn't exist
return apache_request_headers();
}
// otherwise we don't have apache and are just going to have to hope
// that $_SERVER actually contains what we need
$out = array();
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(
" ",
"-",
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
);
$out[$key] = $value;
}
}
return $out;
}
// This function takes a input like a=b&a=c&d=e and returns the parsed
// parameters like this
// array('a' => array('b','c'), 'd' => 'e')
public static function parse_parameters( $input ) {
if (!isset($input) || !$input) return array();
$pairs = split('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = split('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
public static function build_http_query($params) {
if (!$params) return '';
// Urlencode both keys and values
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
$params = array_combine($keys, $values);
// Parameters are sorted by name, using lexicographical byte value ordering.
// Ref: Spec: 9.1.1 (1)
uksort($params, 'strcmp');
$pairs = array();
foreach ($params as $parameter => $value) {
if (is_array($value)) {
// If two or more parameters share the same name, they are sorted by their value
// Ref: Spec: 9.1.1 (1)
natsort($value);
foreach ($value as $duplicate_value) {
$pairs[] = $parameter . '=' . $duplicate_value;
}
} else {
$pairs[] = $parameter . '=' . $value;
}
}
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
}
?>
+10
View File
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+310
View File
@@ -0,0 +1,310 @@
<?php
/*
* Abraham Williams (abraham@abrah.am) http://abrah.am
*
* Basic lib to work with Twitter's OAuth beta. This is untested and should not
* be used in production code. Twitter's beta could change at anytime.
*
* Code based on:
* Fire Eagle code - http://github.com/myelin/fireeagle-php-lib
* twitterlibphp - http://github.com/jdp/twitterlibphp
*
* Modified by Matt Mecham (Invision Power Services)
* - Option to return json_decode in ARRAY not OBJ
* - Added POST / sockets fall back if curl disabled
*/
/* Load OAuth lib. You can find it at http://oauth.net */
require_once('OAuth.php');
/**
* Twitter OAuth class
*/
class TwitterOAuth {
/* Contains the last HTTP status code returned */
public $http_code;
/* Contains the last API call */
public $last_api_call;
/* Set up the API root URL */
public $host = "https://api.twitter.com/1/";
/* Set timeout default */
public $timeout = 30;
/* Set connect timeout */
public $connecttimeout = 30;
/* Verify SSL Cert */
public $ssl_verifypeer = FALSE;
/* Respons format */
public $format = 'json';
/* Decode returne json data */
public $decode_json = TRUE;
/* Allow decoded JSON to be return as an array */
public $json_as_array = TRUE;
/* Immediately retry the API call if the response was not successful. */
//public $retry = TRUE;
/**
* Set API URLS
*/
function accessTokenURL() { return 'https://twitter.com/oauth/access_token'; }
function authenticateURL() { return 'https://twitter.com/oauth/authenticate'; }
function authorizeURL() { return 'https://twitter.com/oauth/authorize'; }
function requestTokenURL() { return 'https://twitter.com/oauth/request_token'; }
/**
* Debug helpers
*/
function lastStatusCode() { return $this->http_status; }
function lastAPICall() { return $this->last_api_call; }
/**
* construct TwitterOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
}
}
/**
* Get a request_token from Twitter
*
* @returns a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback = NULL) {
$parameters = array();
if (!empty($oauth_callback)) {
$parameters['oauth_callback'] = $oauth_callback;
}
$request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* Get the authorize URL
*
* @returns a string
*/
function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
if (is_array($token)) {
$token = $token['oauth_token'];
}
if (empty($sign_in_with_twitter)) {
return $this->authorizeURL() . "?oauth_token={$token}";
} else {
return $this->authenticateURL() . "?oauth_token={$token}";
}
}
/**
* Exchange the request token and secret for an access token and
* secret, to sign API calls.
*
* @returns array("oauth_token" => the access token,
* "oauth_token_secret" => the access secret)
*/
function getAccessToken($oauth_verifier = FALSE) {
$parameters = array();
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
/**
* GET wrappwer for oAuthRequest.
*/
function get($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'GET', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, $this->json_as_array);
}
return $response;
}
/**
* POST wreapper for oAuthRequest.
*/
function post($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'POST', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, $this->json_as_array);
}
return $response;
}
/**
* DELTE wrapper for oAuthReqeust.
*/
function delete($url, $parameters = array()) {
$response = $this->oAuthRequest($url, 'DELETE', $parameters);
if ($this->format === 'json' && $this->decode_json) {
return json_decode($response, $this->json_as_array);
}
return $response;
}
/**
* Format and sign an OAuth / API request
*/
function oAuthRequest($url, $method, $parameters) {
if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
$url = "{$this->host}{$url}.{$this->format}";
}
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
return $this->http($request->to_url(), 'GET');
default:
return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
}
}
/**
* Make an HTTP request
*
* @return API results
*/
function http($url, $method, $postfields = NULL) {
if ( function_exists( 'curl_init' ) AND function_exists("curl_exec") )
{
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->last_api_call = $url;
curl_close ($ci);
if( $response )
{
return $response;
}
}
$url_parts = @parse_url($url);
if ( ! $postfields )
{
$_c = str_replace( '&amp;', '&', $url_parts['query'] );
$_a = array();
foreach( explode( '&', $_c ) as $meh )
{
list( $k, $v ) = explode( '=', $meh );
$_a[ $k ] = urldecode( $v );
}
$postfields = http_build_query( $_a );
}
if ( $method != 'POST' )
{
$data = @file_get_contents( $url );
$this->http_code = ( strstr( $data, 'oauth_token' ) ) ? 200 : 401;
$this->last_api_call = $url;
return trim( $data );
}
else
{
/* Use SSL rather than https */
$url_parts['scheme'] = ( $url_parts['scheme'] == 'https' ) ? 'ssl' : $url_parts['scheme'];
$host = $url_parts['scheme'] . '://' . $url_parts['host'];
$port = ( isset($url_parts['port']) ) ? $url_parts['port'] : ( $url_parts['scheme'] == 'https' || $url_parts['scheme'] == 'ssl' ? 443 : 80 );
if ( !empty( $url_parts["path"] ) )
{
$path = $url_parts["path"];
}
else
{
$path = "/";
}
$header = "$method {$path} HTTP/1.0\r\n";
$header .= "User-Agent: Twitter\r\n";
$header .= "Host: " . str_replace( array( 'http://', 'https://', 'ssl://' ), '', $host ) . "\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($postfields) . "\r\n\r\n";
if ( $fp = fsockopen( $host, $port, $errno, $errstr, $this->timeout ) )
{
socket_set_timeout($fp, $this->timeout);
fwrite($fp, $header . $postfields);
while( ! feof($fp) && ! $status['timed_out'] )
{
$data .= fgets ($fp,8192);
$status = stream_get_meta_data($fp);
}
fclose($fp);
}
/* Strip headers HTTP/1.1 ### ABCD */
$this->http_code = substr( $data, 9, 3 );
$this->last_api_call = $url;
/* Chuncked? */
$_chunked = false;
if( preg_match( "/Transfer\-Encoding:\s*chunked/i", $data ) )
{
$_chunked = true;
}
$tmp = explode("\r\n\r\n", $data, 2);
$data = trim($tmp[1]);
if( $_chunked )
{
$lines = explode( "\n", $data );
array_pop($lines);
array_shift($lines);
$data = implode( "\n", $lines );
}
return $data;
}
}
}