Version 3.3.4

This commit is contained in:
Neo committed 2025-12-19 00:35:52 -08:00
1 parent 78706903a2
commit fb6b5baabc
2206 files changed
+409828 -382984

No files matched your search

+299 -150
View File
@@ -2,21 +2,21 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Static Classes for IP.Board 3
*
* These classes are not required as objects. We have grouped
* together several singletons to prevent multiple file loads
* Last Updated: $Date: 2011-10-06 23:44:10 -0400 (Thu, 06 Oct 2011) $
* Last Updated: $Date: 2012-07-04 13:32:40 -0400 (Wed, 04 Jul 2012) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 12th March 2002
* @version $Revision: 9587 $
* @version $Revision: 11032 $
*
* @author Matt
*/
@@ -28,7 +28,6 @@ $_ipsPowerSettings = array( 'status_sidebar_show_x' => 5,
'ipb_disable_group_psformat' => 0,
'tags_max_truncated_len' => 35,
'max_bbcodes_per_post' => 500,
'topic_marking_keep_days' => 31,
'postpage_contents' => '5,10,15,20,25,30,35,40',
'topicpage_contents' => '5,10,15,20,25,30,35,40',
'member_photo_crop' => 100,
@@ -36,6 +35,8 @@ $_ipsPowerSettings = array( 'status_sidebar_show_x' => 5,
'like_notifications_limit' => 1000,
'actidx_override' => 0,
'signature_line_length' => 200,
'show_x_page_link' => 2,
'post_order_column' => 'pid', // Other valid values: 'post_date'
);
class IPSAdCodeDefault
@@ -566,7 +567,6 @@ class IPSBWOptions
$array[ $key ] = 1;
}
else
{
$array[ $key ] = 0;
}
@@ -629,10 +629,10 @@ class IPSBWOptions
{
/* INIT */
$int = 0;
/* Generate bitwise array */
$bitArray = self::_getBitWiseArray( $type, $app );
if ( ! $bitArray OR ! count( $bitArray ) )
{
return 0;
@@ -662,7 +662,7 @@ class IPSBWOptions
{
$bitArray = array();
$allOptions = ipsRegistry::fetchBitWiseOptions( $app );
if ( is_array( $allOptions ) )
{
if ( isset( $allOptions[ $type ] ) AND is_array( $allOptions[ $type ] ) )
@@ -1309,18 +1309,7 @@ class IPSLib
return false;
}
/**
* Quickly determines if we've got VK enabled and set up
*
* @access public
* @return boolean
*/
static public function vkontakte_enabled()
{
return ( ipsRegistry::$settings['vk_enabled'] AND ipsRegistry::$settings['vk_api_id'] AND ipsRegistry::$settings['vk_secret'] ) ? TRUE : FALSE;
}
/**
* Central setlocale method so we can adjust as needed
*
@@ -1392,9 +1381,6 @@ class IPSLib
switch( $method )
{
case 'vkontakte':
return self::vkontakte_enabled();
break;
case 'facebook':
return self::fbc_enabled();
break;
@@ -1513,32 +1499,118 @@ class IPSLib
*
* @param array array('conf_key' => 'new value')
* @return true/false
* @author MarkWade
*/
static public function updateSettings($update=array())
{
$fields = array_keys($update);
static public function updateSettings( $update=array(), $parseEditorValues=FALSE )
{
//-----------------------------------------
// Load the settings we need to update
//-----------------------------------------
$fields = array_keys( $update );
ipsRegistry::DB()->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN ('" . implode( "','", $fields ) . "')" ) );
ipsRegistry::DB()->execute();
$db_fields = array();
while ( $r = ipsRegistry::DB()->fetch() )
{
$db_fields[ $r['conf_key'] ] = $r;
}
if (empty($db_fields))
if ( empty( $db_fields ) )
{
return false;
}
/* We have to examine $_POST as the custom PHP for some settings
still sets that rather than $value */
$oldPostData = $_POST;
//-----------------------------------------
// Update values
//-----------------------------------------
foreach( $db_fields as $key => $data )
{
$value = str_replace( "&#39;", "'", IPSText::safeslashes($update[ $key ]) );
$value = $value == '' ? "{blank}" : $value;
$value = null;
/* Init */
if ( !is_array( $update[ $key ] ) )
{
if ( $update[ $key ] != $data['conf_default'] )
{
$value = str_replace( "&#39;", "'", IPSText::stripslashes( $update[ $key ] ) );
$value = $value == '' ? "{blank}" : $value;
}
else
{
$value = $data['conf_default'];
}
}
/* Evaluate PHP */
if ( $data['conf_evalphp'] )
{
$data['conf_evalphp'] = str_replace( '&#092;', '\\', $data['conf_evalphp'] );
$save = 1;
ipsRegistry::DB()->update( 'core_sys_conf_settings', array( 'conf_value' => $value ), 'conf_id=' . $data['conf_id'] );
$data['conf_evalphp'] = str_replace( '$this->registry', 'ipsRegistry::instance()', $data['conf_evalphp'] );
$data['conf_evalphp'] = str_replace( '$this->cache', 'ipsRegistry::cache()', $data['conf_evalphp'] );
$data['conf_evalphp'] = str_replace( '$this->DB', 'ipsRegistry::DB()', $data['conf_evalphp'] );
$data['conf_evalphp'] = str_replace( '$this->settings', 'ipsRegistry::$settings', $data['conf_evalphp'] );
$data['conf_evalphp'] = str_replace( '$this->lang', 'ipsRegistry::getClass(\'class_localization\')', $data['conf_evalphp'] );
eval( $data['conf_evalphp'] );
if ( $_POST[ $key ] !== $oldPostData[ $key ] )
{
$value = $_POST[ $key ];
}
/* Was value set? */
if ( $value === null )
{
$value = str_replace( "&#39;", "'", IPSText::stripslashes( $update[ $key ] ) );
$value = $value == '' ? "{blank}" : $value;
}
}
/* Parse */
if ( $parseEditorValues and $data['conf_type'] == 'editor' )
{
IPSText::getTextClass('bbcode')->bypass_badwords = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_html = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
if( trim($value) == '<br>' OR trim($value) == '<br />' )
{
$value = '';
}
else
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
$value = $editor->process( $value );
}
}
/* Strip new lines */
$value = str_replace( "\r", "", $value );
/* Save */
if ( $value != $data['conf_default'] )
{
ipsRegistry::DB()->update( 'core_sys_conf_settings', array( 'conf_value' => $value ), 'conf_id=' . $data['conf_id'] );
}
else if( ( isset( $update[ $key ] ) && $update[ $key ] == '' ) || ( $update[ $key ] == $data['conf_default'] ) || $data['conf_value'] != '' )
{
ipsRegistry::DB()->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), 'conf_id=' . $data['conf_id'] );
}
}
//-----------------------------------------
// Recache
//-----------------------------------------
ipsRegistry::DB()->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_add_cache=1' ) );
$info = ipsRegistry::DB()->execute();
@@ -1557,6 +1629,10 @@ class IPSLib
ipsRegistry::cache()->setCache( 'settings', $settings, array( 'array' => 1 ) );
//-----------------------------------------
// Return
//-----------------------------------------
return true;
}
@@ -1769,22 +1845,14 @@ EOF;
}
}
// FURL Pack select
$furl_templates_filename = 'furlTemplates.php';
if ( IPB_USE_ONLY_ID_FURL )
{
$furl_templates_filename = 'furlIdTemplates.php';
}
/* Loop over the applications and build */
foreach( $apps as $path => $app_dir )
{
if ( is_file( IPS_ROOT_PATH . $path . '/extensions/' . $furl_templates_filename ) )
if ( is_file( IPS_ROOT_PATH . $path . '/extensions/furlTemplates.php' ) )
{
$_SEOTEMPLATES = array();
require( IPS_ROOT_PATH . $path . '/extensions/' . $furl_templates_filename );/*noLibHook*/
require( IPS_ROOT_PATH . $path . '/extensions/furlTemplates.php' );/*noLibHook*/
if ( is_array( $_SEOTEMPLATES ) && count( $_SEOTEMPLATES ) )
{
@@ -2031,7 +2099,7 @@ EOF;
$bbcodes = array();
$currentBbcodes = ipsRegistry::cache()->getCache('bbcode');
$protectedBbcodes = array('right', 'left', 'center', 'b', 'i', 'u', 'url', 'img', 'quote', 'indent', 'snapback',
'list', 'strike', 'sub', 'sup', 'email', 'background', 'color', 'size', 'font'
'list', 'strike', 'sub', 'sup', 'email', 'color', 'size', 'font'
);
/* Remove protected bbcodes */
@@ -2359,9 +2427,10 @@ EOF;
* Get the application title. Uses lang file keys if present.
*
* @param string application
* @param bool Force public title
* @return string Text to show for application title
*/
static public function getAppTitle( $app )
static public function getAppTitle( $app, $forcePublic=false )
{
if ( ! $app )
{
@@ -2370,7 +2439,7 @@ EOF;
return isset( ipsRegistry::getClass('class_localization')->words[ $app . '_display_title' ] ) ?
ipsRegistry::getClass('class_localization')->words[ $app . '_display_title' ] :
( IN_ACP ? ipsRegistry::$applications[ $app ]['app_title'] : ipsRegistry::$applications[ $app ]['app_public_title'] );
( ( IN_ACP AND !$forcePublic ) ? ipsRegistry::$applications[ $app ]['app_title'] : ipsRegistry::$applications[ $app ]['app_public_title'] );
}
/**
@@ -2524,6 +2593,9 @@ EOF;
case 'vncwithunreadcontent':
$_ck = 'can_vnc_unread_content';
break;
case 'tags':
$_ck = 'can_searchTags';
break;
}
/* got anything? */
@@ -2652,7 +2724,7 @@ EOF;
* @param array Array of extensions an application must have to be returned
* @return Array
*/
static public function getEnabledApplications( $extensions=array() )
static public function getEnabledApplications( $extensions=array(), $forceNotFromCache=FALSE )
{
$apps = array();
$extensions = is_string( $extensions ) ? array( $extensions ) : ( is_array( $extensions ) ? $extensions : array() );
@@ -2660,7 +2732,7 @@ EOF;
static $cache = array();
$_key = md5( implode( ',', $extensions ) );
if( $cache[ $_key ] )
if( $cache[ $_key ] and !$forceNotFromCache )
{
return $cache[ $_key ];
}
@@ -3153,11 +3225,12 @@ EOF;
*/
static public function shareLinks( $title='', $params=array() )
{
$url = ( isset( $params['url'] ) ) ? $params['url'] : '';
$cssClass = ( isset( $params['cssClass'] ) ) ? $params['cssClass'] : 'topic_share left';
$group = ( isset( $params['group'] ) ) ? $params['group'] : 'global';
$bit = ( isset( $params['bit'] ) ) ? $params['bit'] : 'shareLinks';
$skip = ( isset( $params['skip'] ) ) ? $params['skip'] : array();
$url = isset( $params['url'] ) ? $params['url'] : '';
$cssClass = isset( $params['cssClass'] ) ? $params['cssClass'] : 'topic_share left';
$group = isset( $params['group'] ) ? $params['group'] : 'global';
$bit = isset( $params['bit'] ) ? $params['bit'] : 'shareLinks';
$skip = isset( $params['skip'] ) ? $params['skip'] : array();
$override = isset( $params['overrideApp'] ) ? $params['overrideApp'] : '';
/* Disabled? */
if ( ! ipsRegistry::$settings['sl_enable'] )
@@ -3173,6 +3246,7 @@ EOF;
$canon = ipsRegistry::getClass('output')->fetchRootDocUrl();
$url = ( $url ) ? $url : ipsRegistry::$settings['this_url'];
$raw = $url;
$canon = IPSText::base64_encode_urlSafe( ( $canon ) ? $canon : $url );
$title = IPSText::base64_encode_urlSafe( $title );
$url = IPSText::base64_encode_urlSafe( $url );
@@ -3194,7 +3268,9 @@ EOF;
}
else
{
$cache[ $key ]['_url'] = ( $data['share_canonical'] ) ? $canon : $url;
$cache[ $key ]['_rawUrl'] = $raw;
$cache[ $key ]['overrideApp'] = $override;
$cache[ $key ]['_url'] = $data['share_canonical'] ? $canon : $url;
}
}
@@ -3286,28 +3362,21 @@ EOF;
/**
* Has an active license or not
* @param boolean Allow perpetual license to count.
* @return boolean
* @return true
*/
static public function hasActiveLicense( $allowPerpetual=true )
{
//return true;
$licenseData = ipsRegistry::cache()->getCache( 'licenseData' );
if ( ( ! $licenseData OR ! $licenseData['key']['_expires'] OR $licenseData['key']['_expires'] < IPS_UNIX_TIME_NOW OR $licenseData['key']['_expires'] == 9999999999 ) )
{
return false;
}
if ( $allowPerpetual !== true )
{
if ( stristr( $licenseData['name'], 'perpetual' ) )
{
return false;
}
}
return true;
}
/**
* Is the archive DB on another server?
* @return boolean
*/
static public function isUsingRemoteArchiveDB()
{
return ( ipsRegistry::$settings['archive_remote_sql_database'] && ipsRegistry::$settings['archive_remote_sql_user'] ) ? true : false;
}
}
/**
@@ -3479,19 +3548,19 @@ class IPSDebug
$errfile = str_replace( @getcwd(), "", $errfile );
$log = false;
$message = "> [$errno] $errstr\n> > Строка: $errline\n> > Файл: $errfile";
$message = "> [$errno] $errstr\n> > Line: $errline\n> > File: $errfile";
/* What do we have? */
switch ($errno)
{
case E_ERROR:
$log = true;
echo "<b>Ошибка</b> [$errno] $errstr (Строка: $errline в $errfile)<br />\n";
echo "<b>IPB ERROR</b> [$errno] $errstr (Line: $errline of $errfile)<br />\n";
exit(1);
break;
case E_WARNING:
$log = true;
echo "<b>Предупреждение</b> [$errno] $errstr (Строка: $errline в $errfile)<br />\n";
echo "<b>IPB WARNING</b> [$errno] $errstr (Line: $errline of $errfile)<br />\n";
break;
case E_NOTICE:
$log = true;
@@ -3615,7 +3684,7 @@ class IPSDebug
{
if ( $lineNumber )
{
print "<h4>Ошибка в шаблоне: <a href='#line{$lineNumber}'>" . $lineNumber . "</a></h4>";
print "<h4>Parse Error on line: <a href='#line{$lineNumber}'>" . $lineNumber . "</a></h4>";
}
else
{
@@ -3791,7 +3860,7 @@ class IPSDebug
| Can also be obtained from COM, but it's extremely slow...
---------------------------------------------------------------*/
$serverstats = @shell_exec('typeperf \"Processor(_Total)\% Processor Time\" -sc 1');
$serverstats = @shell_exec('typeperf "Processor(_Total)\% Processor Time" -sc 1');
if( $serverstats )
{
@@ -4100,6 +4169,21 @@ class IPSText
}
}
static public function jsonEncodeForTemplate( $data )
{
/* Using UTF-8 - it's an easy thing */
if ( IPS_DOC_CHAR_SET == 'UTF-8' )
{
return json_encode( $data );
}
/* convert */
array_walk_recursive( $data, array( 'IPSText', 'arrayWalkCallbackConvert' ) );
$jsonEncoded = json_encode( $data );
return IPSText::convertCharsets( $jsonEncoded, "UTF-8", IPS_DOC_CHAR_SET );
}
/**
* Get helper classes
* Used here to allow classes to be loaded and used as-and-when they're needed
@@ -4150,55 +4234,27 @@ class IPSText
*
* Mostly used to ensure that data designed for UTF-8 XML files is actually stored as UTF-8 from
* 'flat' files that may not be saved as UTF-8.
* Most likely this will have to be expanded to support different char sets eventually.
*
* @param string Data in
* @return string Data out
*/
static public function encodeForXml( $string )
{
if ( strtolower( IPS_DOC_CHAR_SET ) != 'utf-8' )
if ( function_exists( 'mb_detect_encoding' ) )
{
$encoding = mb_detect_encoding( $string );
if ( $encoding != 'UTF-8' )
{
$string = IPSText::convertCharsets( $string, $encoding );
}
}
elseif ( strtolower( IPS_DOC_CHAR_SET ) == 'utf-8' )
{
$string = utf8_encode( $string );
}
return $string;
}
/**
* Convert russian mounth names to english
*
* @access public
* @param string Date
* @return string Converted date
*/
static public function monthNameRu2En( $text )
{
return str_replace( array('Январь','Февраль','Март','Апрель','Май','Июнь,','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'), array('January','February','March','April','May','June','July','August','September','October','November','December'), $text );
}
static public function transliterate( $text )
{
return str_replace( array('а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','э','ю','я','ы','ь','ъ'), array('a','b','v','g','d','e','e','zh','z','i','i','k','l','m','n','o','p','r','s','t','u','f','h','c','ch','sh','sh','a','ju','ja','i','',''), $text);
}
static public function makeSeoTransliterate( $text )
{
if ( IPB_USE_SEO_TRANSLIT )
{
$text = urldecode($text);
$text = self::transliterate( $text );
$text = preg_replace('#[^a-z0-9-]#', '', $text);
$text = urlencode($text);
}
return $text;
}
/**
* Make an SEO title for use in the URL
@@ -4237,7 +4293,7 @@ class IPSText
}
/* Finish off */
$text = mb_strtolower($text);
$text = strtolower($text);
if ( strtolower( IPS_DOC_CHAR_SET ) == 'utf-8' )
{
@@ -4256,8 +4312,6 @@ class IPSText
$text = preg_replace( "#-{2,}#", '-', $text );
$text = trim($text, '-');
$text = self::makeSeoTransliterate( $text );
IPSDebug::addMessage( "<span style='color:red'>makeSeoTitle ($text) called</span>" );
return ( $text ) ? $text : '-';
@@ -4320,7 +4374,7 @@ class IPSText
{
$_chr = array(
/* Latin-1 Supplement */
chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
chr(195).chr(128) => 'Ae', chr(195).chr(129) => 'A',
chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
@@ -4330,12 +4384,12 @@ class IPSText
chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
chr(195).chr(150) => 'Oe', chr(195).chr(153) => 'U',
chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
chr(195).chr(156) => 'Ue', chr(195).chr(157) => 'Y',
chr(195).chr(159) => 'ss', chr(195).chr(160) => 'a',
chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
chr(195).chr(163) => 'a', chr(195).chr(164) => 'ae',
chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
@@ -4343,11 +4397,10 @@ class IPSText
chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
chr(195).chr(191) => 'y',
chr(195).chr(181) => 'o', chr(195).chr(182) => 'oe',
chr(195).chr(185) => 'u', chr(195).chr(186) => 'u',
chr(195).chr(187) => 'u', chr(195).chr(188) => 'ue',
chr(195).chr(189) => 'y', chr(195).chr(191) => 'y',
/* Latin Extended-A */
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
@@ -4390,13 +4443,13 @@ class IPSText
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -4540,6 +4593,23 @@ class IPSText
return $string;
}
/**
* Strips out all non UTF-8 characters from a string
* This is best used when you have already converted / got UTF-8 data
* @param string In
* @return string Cleaned
*/
public static function stripNonUtf8( $string )
{
$string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]|(?<=^|[\x00-\x7F])[\x80-\xBF]+|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/', '?', $string );
$string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]|\xED[\xA0-\xBF][\x80-\xBF]/S','?', $string );
return $string;
}
/**
* Decodes long named HTML entities in a string &eacute; without affecting other HTML entities (&lt; etc) etc
* @param string Raw string
@@ -4547,13 +4617,21 @@ class IPSText
*/
public static function decodeNamedHtmlEntities( $string )
{
/* Some manual conversions */
$manual = array( 'Alpha' => 'A', 'Beta' => 'B', 'alpha' => 'a', 'beta' => 'b' );
foreach( $manual as $o => $r )
{
$string = str_replace( '&' . $o . ';', $r, $string );
}
preg_match_all( '#&([^;\s]+?);#', $string, $matches );
$entities = array();
$notList = array( 'amp' );
$notList = array( 'amp', 'para', 'middot', 'gt', 'lt' );
foreach( $matches[0] as $word )
{
if ( preg_match( '#^&([a-zA-Z]{3,8});$#', $word, $match ) )
if ( preg_match( '#^&([a-zA-Z]{2,8});$#', $word, $match ) )
{
if ( ! in_array( $match[1], $notList ) )
{
@@ -4561,12 +4639,14 @@ class IPSText
}
}
}
$translated = @explode( ' ', @html_entity_decode( @implode( ' ', $entities ), ENT_NOQUOTES, IPS_DOC_CHAR_SET ) );
/* -15 is the same as -1 but with Euro plus French and Finnish */
$charSet = ( IPS_DOC_CHAR_SET == 'ISO-8859-1' ) ? 'ISO-8859-15' : IPS_DOC_CHAR_SET;
$translated = @explode( ' ', @html_entity_decode( @implode( ' ', $entities ), ENT_NOQUOTES, $charSet ) );
if ( is_array( $translated ) AND count( $translated ) AND count( $translated ) == count( $entities ) )
{
return str_ireplace( $entities, $translated, $string );
return str_replace( $entities, $translated, $string );
}
return $string;
@@ -4863,7 +4943,7 @@ class IPSText
return FALSE;
}
if ( preg_match( '#[\;\#\n\r\*\'\"<>&\%\!\(\)\{\}\[\]\?\\/\s]#', $email ) )
if ( preg_match( '#[\;\#\n\r\*\'\"<>&\%\!\(\)\{\}\[\]\?\\/\s\,]#', $email ) )
{
return FALSE;
}
@@ -4937,12 +5017,23 @@ class IPSText
*/
static public function searchHighlight( $text, $highlight )
{
//-----------------------------------------
// INIT
//-----------------------------------------
/* No highlight to do (1)? No point in wasting time then.. */
if ( $highlight == '' )
{
return $text;
}
$highlight = self::parseCleanValue( urldecode( $highlight ) );
/* No highlight to do (2)? No point in wasting time then.. */
if ( $highlight == '' )
{
return $text;
}
/* Init some more vars */
$loosematch = 1;//strstr( $highlight, '*' ) ? 1 : 0;
$isPhrase = preg_match( '#("|&(amp;)?quot;)#', $highlight );
$keywords = str_replace( '*', '', str_replace( "+", " ", str_replace( "++", "+", str_replace( '-', '', trim($highlight) ) ) ) );
$keywords = str_replace( '&quot;', '', str_replace( '\\', '&#092;', str_replace( '&amp;quot;', '', $keywords ) ) );
$word_array = array();
@@ -4980,7 +5071,7 @@ class IPSText
$keywords = str_replace( $match[0], '', $keywords );
}
}
else if ( strstr( $keywords, ' ' ) )
else if ( ! $isPhrase && strstr( $keywords, ' ' ) )
{
$word_array = explode( ' ', str_replace( ' ', ' ', $keywords ) );
}
@@ -5293,7 +5384,7 @@ class IPSText
self::$classConvertCharset->method = 'internal';
}
}
$text = self::$classConvertCharset->convertEncoding( $text, $original_cset, $destination_cset );
/* Experimental - convert \u#### to html entity */
@@ -5606,6 +5697,11 @@ class IPSText
*/
static public function stripslashes($t)
{
if( is_array($t) )
{
return $t;
}
if ( IPS_MAGIC_QUOTES )
{
$t = stripslashes($t);
@@ -5683,6 +5779,7 @@ class IPSText
static public function UNhtmlspecialchars($t="")
{
$t = str_replace( "&amp;" , "&", $t );
$t = str_replace( "&#38;" , "&", $t );
$t = str_replace( "&lt;" , "<", $t );
$t = str_replace( "&gt;" , ">", $t );
$t = str_replace( "&quot;", '"', $t );
@@ -5782,13 +5879,12 @@ class IPSText
* @see http://en.wikipedia.org/wiki/Space_(punctuation)
* @see http://www.ascii.cl/htmlcodes.htm
*/
//$t = str_replace( chr(160), ' ', $t );
$t = str_replace( chr(160), ' ', $t );
$t = str_replace( chr(173), ' ', $t );
//$t = str_replace( chr(240), ' ', $t ); -> latin small letter eth
//$t = str_replace( chr(0xA0), "", $t ); //Remove sneaky spaces Same as chr 160
//$t = str_replace( chr(0x11f9), "", $t); //Remove sneaky spaces
//$t = str_replace( chr(0x2004), "", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0x2005), "", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0x2006), "", $t ); //Remove sneaky spaces
@@ -5799,12 +5895,37 @@ class IPSText
//$t = str_replace( chr(0x200D), " ", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0x202F), " ", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0x205F), " ", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0x2060), "", $t ); //Remove sneaky spaces
//$t = str_replace( chr(0xFEFF), "", $t ); //Remove sneaky spaces
}
return $t;
}
/**
* URL encode safe with IPB FURLS
* @param string $data
* @return string Data
*/
static public function urlencode_furlSafe( $data )
{
$data = str_replace( '/', '%2F', $data );
return urlencode( $data );
}
/**
* URL encode safe with IPB FURLS
* @param string $data
* @return string Data
*/
static public function urldecode_furlSafe( $data )
{
$data = str_replace( '%25', '%', $data );
return urldecode( $data );
}
/**
* Base64 encode for URLs
*
@@ -5813,7 +5934,7 @@ class IPSText
*/
static public function base64_encode_urlSafe( $data )
{
return strtr( base64_encode( $data ), '+/=', '-_,' );;
return strtr( base64_encode( $data ), '+/=', '-_,' );
}
/**
@@ -5826,4 +5947,32 @@ class IPSText
{
return base64_decode( strtr( $data, '-_,', '+/=' ) );
}
/**
* Wrapper for PHPs strip_tags. Makes < and > not part of tags safe
* Based on @link http://www.php.net/manual/en/function.strip-tags.php#89309
* @param string $text
* @param string $allowed
*/
static public function stripTags( $text, $allowed='' )
{
$strs = explode( '<', $text );
$res = $strs[0];
for( $i=1 ; $i < count( $strs ) ; $i++ )
{
if ( ! strpos( $strs[$i], '>' ) )
{
$res = $res . '&#0000001;' . $strs[$i];
}
else
{
$res = $res . '<' . $strs[$i];
}
}
$text = strip_tags( $res, $allowed );
return str_replace( '&#0000001;', '<', $text );
}
}
+9 -9
View File
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
+478 -475
View File
@@ -1,476 +1,479 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Primary controller
* Last Updated: $LastChangedDate: 2011-09-16 07:16:26 -0400 (Fri, 16 Sep 2011) $
* </pre>
*
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 14th May 2003
* @version $Rev: 9496 $
*/
/**
* Class "Controller"
* A very simple public facing interface to resolve incoming data into
* a command class
*
* @author Matt Mecham
* @since Wednesday 14th May 2008
* @package IP.Board
*/
class ipsController
{
/**
* Registry reference
*
* @access protected
* @var object
*/
protected $registry;
/**
* Command
*
* @access public
* @var string
*/
static public $cmd;
/**
* Constructor
*
* @access private
* @return @e void
*/
private function __construct() { }
/**
* Public facing function to run the controller
*
* @access public
* @return @e void
*/
static public function run()
{
$instance = new ipsController();
$instance->init();
$instance->handleRequest();
}
/**
* Initialize ipsRegistry and this class
*
* @access protected
* @return @e void
*/
protected function init()
{
$this->registry = ipsRegistry::instance();
$this->registry->init();
}
/**
* Handle the incoming request using the command resolver
*
* @access protected
* @return @e void
*/
protected function handleRequest()
{
$cmd_r = new ipsController_CommandResolver();
try
{
self::$cmd = $cmd_r->getCommand( $this->registry );
}
catch( Exception $e )
{
$msg = $e->getMessage();
/* An error occured, so throw a 404 */
try
{
/* The following patch prevents links such as /admin/index.php?adsess=123&app=anyrandomnamehere&module=login&do=login-complete from loading
an ACP error screen complete with wrapper, which may expose the applications that are installed to an end user.
This issue was reported by Christopher Truncer via the IPS ticket system. */
if( IN_ACP AND !$this->registry->member()->getProperty('member_id') )
{
$this->registry->getClass('output')->silentRedirect( ipsRegistry::$settings['base_url'] );
}
$this->registry->getClass('output')->showError( 'incorrect_furl', 404, null, null, 404 );
}
catch( Exception $e )
{
print $msg;
exit();
}
}
IPSDebug::setMemoryDebugFlag( "Everything up until execute call", 0 );
self::$cmd->execute( $this->registry );
}
}
/**
* Class "Command Resolver"
* Resolves the incoming data
*
* @author Matt Mecham
* @since Wednesday 14th May 2008
* @package IP.Board
*/
class ipsController_CommandResolver
{
/**#@+
* Internal strings to remember
*
* @access protected
* @var string
*/
protected static $base_cmd;
protected static $default_cmd;
protected static $modules_dir = 'modules_public';
protected static $class_dir = 'public';
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
public function __construct()
{
if ( ! self::$base_cmd )
{
self::$base_cmd = ipsRegistry::$current_module == 'ajax' ? new ReflectionClass( 'ipsAjaxCommand' ) : new ReflectionClass( 'ipsCommand' );
self::$default_cmd = new ipsCommand_default();
self::$modules_dir = ( IPS_AREA != 'admin' ) ? 'modules_public' : 'modules_admin';
self::$class_dir = ( IPS_AREA != 'admin' ) ? 'public' : 'admin';
}
}
/**
* Retreive the command
*
* @access public
* @param object ipsRegistry reference
* @return object
*/
public function getCommand( ipsRegistry $registry )
{
$_NOW = IPSDebug::getMemoryDebugFlag();
$module = ipsRegistry::$current_module;
$section = ipsRegistry::$current_section;
$filepath = IPSLib::getAppDir( IPS_APP_COMPONENT ) . '/' . self::$modules_dir . '/' . $module . '/';
/* Bug Fix #21009 */
if ( ! ipsRegistry::$applications[ IPS_APP_COMPONENT ]['app_enabled'] )
{
throw new Exception( "The specified application has been disabled" );
}
if ( !IN_ACP and !IPSLib::moduleIsEnabled( $module, IPS_APP_COMPONENT ) and $module != 'ajax' )
{
throw new Exception( "The specified module has been disabled" );
}
/* Got a section? */
if ( ! $section )
{
if ( is_file( $filepath . 'defaultSection.php' ) )
{
$DEFAULT_SECTION = '';
include( $filepath . 'defaultSection.php' );/*noLibHook*/
if ( $DEFAULT_SECTION )
{
$section = $DEFAULT_SECTION;
ipsRegistry::$current_section = $section;
}
}
}
$_classname = self::$class_dir . '_' . IPS_APP_COMPONENT . '_' . $module . '_';
/* Rarely used, let's leave file_exists which is faster for non-existent files */
if ( file_exists( $filepath . 'manualResolver.php' ) )
{
$classname = IPSLib::loadActionOverloader( $filepath . 'manualResolver.php' , $_classname . 'manualResolver' );
}
else if ( is_file( $filepath . $section . '.php' ) )
{
$classname = IPSLib::loadActionOverloader( $filepath . $section . '.php' , $_classname . $section );
}
IPSDebug::setMemoryDebugFlag( "Controller getCommand executed" );
if ( class_exists( $classname ) )
{
$cmd_class = new ReflectionClass( $classname );
if ( $cmd_class->isSubClassOf( self::$base_cmd ) )
{
return $cmd_class->newInstance();
}
else
{
throw new Exception( "$section в $module не существует!" );
}
}
# Fudge it to return just the default object
return clone self::$default_cmd;
}
}
abstract class ipsCommand
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
final public function __construct()
{
}
/**
* Make the registry shortcuts
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function makeRegistryShortcuts( ipsRegistry $registry )
{
/* Make registry objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->memberData = IPSMember::setUpModerator( $this->memberData );
}
/**
* Execute the command (call doExecute)
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function execute( ipsRegistry $registry )
{
//$registry->getClass('class_permissions')
$this->makeRegistryShortcuts( $registry );
$this->doExecute( $registry );
}
/**
* Do execute method (must be overriden)
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected abstract function doExecute( ipsRegistry $registry );
}
/**
* Abstract class for handling ajax requests
*/
abstract class ipsAjaxCommand
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
protected $ajax;
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
final public function __construct()
{
}
/**
* Magic function to catch all the ajax methods
*
* @access public
* @param string $func Function name being called
* @param array $arguments Array of parameters
* @return mixed
*/
public function __call( $func, $arguments )
{
if( method_exists( $this->ajax, $func ) )
{
return call_user_func_array( array( $this->ajax, $func ), $arguments );
}
}
/**
* Creates all the registry shorctus
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function makeRegistryShortcuts( ipsRegistry $registry )
{
/* Make registry objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->memberData = IPSMember::setUpModerator( $this->memberData );
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
$this->ajax = new $classToLoad();
IPSDebug::fireBug( 'registerExceptionHandler' );
IPSDebug::fireBug( 'registerErrorHandler' );
}
/**
* Executes the ajax request, checks secure key
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function execute( ipsRegistry $registry )
{
/* Setup Shortcuts First */
$this->makeRegistryShortcuts( $registry );
/* Check the secure key */
$this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
//if( $this->request['secure_key'] && $this->request['secure_key'] != $this->member->form_hash )
if( $this->request['secure_key'] != $this->member->form_hash )
{
IPSDebug::fireBug( 'error', array( "The security key did not match the member's form hash" ) );
$this->returnString( 'nopermission' );
}
$this->doExecute( $registry );
}
/**
* Do execute method (must be overriden)
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected abstract function doExecute( ipsRegistry $registry );
}
class ipsCommand_default extends ipsCommand
{
/**
* Do execute method
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected function doExecute( ipsRegistry $registry )
{
$modules_dir = ( IPS_AREA != 'admin' ) ? 'modules_public' : 'modules_admin';
$filepath = IPSLib::getAppDir( IPS_APP_COMPONENT ) . '/' . $modules_dir . '/' . ipsRegistry::$current_module . '/' . ipsRegistry::$current_section . '.php';
$filepath = str_replace( DOC_IPS_ROOT_PATH, '', $filepath );
//-----------------------------------------
// Redirect to board index
//-----------------------------------------
if ( ! (IPS_APP_COMPONENT == 'forums' AND ipsRegistry::$current_module == 'forums' AND ipsRegistry::$current_section == 'boards') )
{
if( IPB_THIS_SCRIPT == 'admin' )
{
$registry->output->silentRedirect( ipsRegistry::$settings['_base_url'] );
}
else
{
$registry->output->silentRedirect( ipsRegistry::$settings['_original_base_url'] );
}
}
//-----------------------------------------
// Uh oh, this is a big one.. (no forums app)
//-----------------------------------------
if ( ! is_file( $filepath ) )
{
$this->registry->getClass('output')->showError( array( 'command_file_missing', $filepath ), 401100, null, null, 404 );
}
else
{
$this->registry->getClass('output')->showError( array( 'command_class_incorrect', $filepath ), 401200, null, null, 404 );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Primary controller
* Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 14th May 2003
* @version $Rev: 10914 $
*/
/**
* Class "Controller"
* A very simple public facing interface to resolve incoming data into
* a command class
*
* @author Matt Mecham
* @since Wednesday 14th May 2008
* @package IP.Board
*/
class ipsController
{
/**
* Registry reference
*
* @access protected
* @var object
*/
protected $registry;
/**
* Command
*
* @access public
* @var string
*/
static public $cmd;
/**
* Constructor
*
* @access private
* @return @e void
*/
private function __construct() { }
/**
* Public facing function to run the controller
*
* @access public
* @return @e void
*/
static public function run()
{
$instance = new ipsController();
$instance->init();
$instance->handleRequest();
}
/**
* Initialize ipsRegistry and this class
*
* @access protected
* @return @e void
*/
protected function init()
{
$this->registry = ipsRegistry::instance();
$this->registry->init();
}
/**
* Handle the incoming request using the command resolver
*
* @access protected
* @return @e void
*/
protected function handleRequest()
{
$cmd_r = new ipsController_CommandResolver();
try
{
self::$cmd = $cmd_r->getCommand( $this->registry );
}
catch( Exception $e )
{
$msg = $e->getMessage();
/* An error occured, so throw a 404 */
try
{
/* The following patch prevents links such as /admin/index.php?adsess=123&app=anyrandomnamehere&module=login&do=login-complete from loading
an ACP error screen complete with wrapper, which may expose the applications that are installed to an end user.
This issue was reported by Christopher Truncer via the IPS ticket system. */
if( IN_ACP AND !$this->registry->member()->getProperty('member_id') )
{
$this->registry->getClass('output')->silentRedirect( ipsRegistry::$settings['base_url'] );
}
$this->registry->getClass('output')->showError( 'incorrect_furl', 404, null, null, 404 );
}
catch( Exception $e )
{
print $msg;
exit();
}
}
IPSDebug::setMemoryDebugFlag( "Everything up until execute call", 0 );
self::$cmd->execute( $this->registry );
}
}
/**
* Class "Command Resolver"
* Resolves the incoming data
*
* @author Matt Mecham
* @since Wednesday 14th May 2008
* @package IP.Board
*/
class ipsController_CommandResolver
{
/**#@+
* Internal strings to remember
*
* @access protected
* @var string
*/
protected static $base_cmd;
protected static $default_cmd;
protected static $modules_dir = 'modules_public';
protected static $class_dir = 'public';
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
public function __construct()
{
if ( ! self::$base_cmd )
{
self::$base_cmd = ipsRegistry::$current_module == 'ajax' ? new ReflectionClass( 'ipsAjaxCommand' ) : new ReflectionClass( 'ipsCommand' );
self::$default_cmd = new ipsCommand_default();
self::$modules_dir = ( IPS_AREA != 'admin' ) ? 'modules_public' : 'modules_admin';
self::$class_dir = ( IPS_AREA != 'admin' ) ? 'public' : 'admin';
}
}
/**
* Retreive the command
*
* @access public
* @param object ipsRegistry reference
* @return object
*/
public function getCommand( ipsRegistry $registry )
{
$_NOW = IPSDebug::getMemoryDebugFlag();
$module = ipsRegistry::$current_module;
$section = ipsRegistry::$current_section;
$filepath = IPSLib::getAppDir( IPS_APP_COMPONENT ) . '/' . self::$modules_dir . '/' . $module . '/';
/* Bug Fix #21009 */
if ( ! ipsRegistry::$applications[ IPS_APP_COMPONENT ]['app_enabled'] )
{
throw new Exception( "The specified application has been disabled" );
}
if ( !IN_ACP and !IPSLib::moduleIsEnabled( $module, IPS_APP_COMPONENT ) and $module != 'ajax' )
{
throw new Exception( "The specified module has been disabled" );
}
/* Got a section? */
if ( ! $section )
{
if ( is_file( $filepath . 'defaultSection.php' ) )
{
$DEFAULT_SECTION = '';
include( $filepath . 'defaultSection.php' );/*noLibHook*/
if ( $DEFAULT_SECTION )
{
$section = $DEFAULT_SECTION;
ipsRegistry::$current_section = $section;
}
}
}
$_classname = self::$class_dir . '_' . IPS_APP_COMPONENT . '_' . $module . '_';
/* Rarely used, let's leave file_exists which is faster for non-existent files */
if ( file_exists( $filepath . 'manualResolver.php' ) )
{
$classname = IPSLib::loadActionOverloader( $filepath . 'manualResolver.php' , $_classname . 'manualResolver' );
}
else if ( is_file( $filepath . $section . '.php' ) )
{
$classname = IPSLib::loadActionOverloader( $filepath . $section . '.php' , $_classname . $section );
}
IPSDebug::setMemoryDebugFlag( "Controller getCommand executed" );
if ( class_exists( $classname ) )
{
$cmd_class = new ReflectionClass( $classname );
if ( $cmd_class->isSubClassOf( self::$base_cmd ) )
{
return $cmd_class->newInstance();
}
else
{
throw new Exception( "$section in $module does not exist!" );
}
}
else
{
throw new Exception( "$classname does not exist!" );
}
# Fudge it to return just the default object
return clone self::$default_cmd;
}
}
abstract class ipsCommand
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
final public function __construct()
{
}
/**
* Make the registry shortcuts
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function makeRegistryShortcuts( ipsRegistry $registry )
{
/* Make registry objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->memberData = IPSMember::setUpModerator( $this->memberData );
}
/**
* Execute the command (call doExecute)
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function execute( ipsRegistry $registry )
{
//$registry->getClass('class_permissions')
$this->makeRegistryShortcuts( $registry );
$this->doExecute( $registry );
}
/**
* Do execute method (must be overriden)
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected abstract function doExecute( ipsRegistry $registry );
}
/**
* Abstract class for handling ajax requests
*/
abstract class ipsAjaxCommand
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
protected $ajax;
/**#@-*/
/**
* Constructor
*
* @access public
* @return @e void
*/
final public function __construct()
{
}
/**
* Magic function to catch all the ajax methods
*
* @access public
* @param string $func Function name being called
* @param array $arguments Array of parameters
* @return mixed
*/
public function __call( $func, $arguments )
{
if( method_exists( $this->ajax, $func ) )
{
return call_user_func_array( array( $this->ajax, $func ), $arguments );
}
}
/**
* Creates all the registry shorctus
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function makeRegistryShortcuts( ipsRegistry $registry )
{
/* Make registry objects */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->memberData = IPSMember::setUpModerator( $this->memberData );
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
$this->ajax = new $classToLoad();
IPSDebug::fireBug( 'registerExceptionHandler' );
IPSDebug::fireBug( 'registerErrorHandler' );
}
/**
* Executes the ajax request, checks secure key
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function execute( ipsRegistry $registry )
{
/* Setup Shortcuts First */
$this->makeRegistryShortcuts( $registry );
/* Check the secure key */
$this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
if( $this->request['secure_key'] != $this->member->form_hash )
{
IPSDebug::fireBug( 'error', array( "The security key did not match the member's form hash" ) );
$this->returnString( 'nopermission' );
}
$this->doExecute( $registry );
}
/**
* Do execute method (must be overriden)
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected abstract function doExecute( ipsRegistry $registry );
}
class ipsCommand_default extends ipsCommand
{
/**
* Do execute method
*
* @access protected
* @param object ipsRegistry reference
* @return @e void
*/
protected function doExecute( ipsRegistry $registry )
{
$modules_dir = ( IPS_AREA != 'admin' ) ? 'modules_public' : 'modules_admin';
$filepath = IPSLib::getAppDir( IPS_APP_COMPONENT ) . '/' . $modules_dir . '/' . ipsRegistry::$current_module . '/' . ipsRegistry::$current_section . '.php';
$filepath = str_replace( DOC_IPS_ROOT_PATH, '', $filepath );
//-----------------------------------------
// Redirect to board index
//-----------------------------------------
if ( ! (IPS_APP_COMPONENT == 'forums' AND ipsRegistry::$current_module == 'forums' AND ipsRegistry::$current_section == 'boards') )
{
if( IPB_THIS_SCRIPT == 'admin' )
{
$registry->output->silentRedirect( ipsRegistry::$settings['_base_url'] );
}
else
{
$registry->output->silentRedirect( ipsRegistry::$settings['_original_base_url'] );
}
}
//-----------------------------------------
// Uh oh, this is a big one.. (no forums app)
//-----------------------------------------
if ( ! is_file( $filepath ) )
{
$this->registry->getClass('output')->showError( array( 'command_file_missing', $filepath ), 401100, null, null, 404 );
}
else
{
$this->registry->getClass('output')->showError( array( 'command_class_incorrect', $filepath ), 401200, null, null, 404 );
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,98 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Mobile app methods
* Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 14th May 2003
* @version $Rev: 10914 $
*/
/**
* @author Matt Mecham
* @since Wednesday 9th May 2012
* @package IP.Board
*/
class ipsMobileApp
{
/* Never convert these fields */
static public $noConvertFields = array( 'ips_username', 'ips_password' );
/**
* Constructor
*
* @access private
* @return @e void
*/
public function __construct()
{
$this->convertIncoming();
}
/**
* Initialize ipsRegistry and this class
*
* @access protected
* @return @e void
*/
protected function convertIncoming()
{
# GET first
$input = $this->_recurse( $_GET, array() );
# Then overwrite with POST
ipsRegistry::$request = $this->_recurse( $_POST, $input );
/* Reset $_GET and $_POST */
array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = ipsMobileApp::convert($key, $value);' ) );
array_walk_recursive( $_GET , create_function( '&$value, $key', '$value = ipsMobileApp::convert($key, $value);' ) );
}
/**
* Recursively parse stuff
*/
private function _recurse( &$data, $input=array(), $iteration=0 )
{
if ( $iteration >= 20 )
{
return $input;
}
if ( is_array( $data ) )
{
foreach( $data as $k => $v )
{
if ( is_array( $v ) )
{
$input[ $k ] = $this->_recurse( $data[ $k ], array(), $iteration + 1 );
}
else
{
$v = self::convert( $k, $v );
$input[ $k ] = IPSText::parseCleanValue( $v, true );
}
}
}
return $input;
}
/**
* Parses the content
*/
public static function convert( $k, $v )
{
return ( is_string( $v ) && ( ! in_array( $k, self::$noConvertFields ) ) ) ? IPSText::convertCharsets( $v, 'UTF-8', IPS_DOC_CHAR_SET ) : $v;
}
}
File diff suppressed because it is too large. Load diff
+111 -111
View File
@@ -1,111 +1,111 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Advertisements
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 17th February 2010
* @version $Revision: 8644 $
*/
class IPSAdCode extends IPSAdCodeDefault
{
/**
* Constructor
*
*/
public function __construct( ipsRegistry $registry )
{
return parent::__construct( $registry );
}
/**
* Checks to see if the specified member group can view ads
*
* @access public
*
* @param integer $group_id Group to check
* @return bool
*/
public function userCanViewAds()
{
/* Check to see if the system is globally disabled */
if( ! ipsRegistry::$settings['ad_code_global_enabled'] )
{
return false;
}
/* Check to see if this member group can view ads */
if( ipsRegistry::$settings['ad_code_exempt_groups'] )
{
if( ipsMember::isInGroup( ipsRegistry::member()->fetchMemberData(), explode( ',', ipsRegistry::$settings['ad_code_exempt_groups'] ) ) )
{
return false;
}
}
return true;
}
/**
* Sets global advertising code for display
*
* @access public
*
* @param string $position header or footer
* @param string $code Key for code to be displayed at specified position
* @return @e void
*/
public function setGlobalCode( $position, $code )
{
$code = $this->settings[ $code ];
if( $position == 'header' )
{
$this->headerCode = $code;
}
else if( $position == 'footer' )
{
$this->footerCode = $code;
}
}
/**
* Retrieves global advertising code for display
*
* @access public
*
* @param string $position header or footer
* @param string $code Code to be displayed at specified position
* @return @e void
*/
public function getGobalCode( $position )
{
if( $position == 'header' )
{
return $this->headerCode;
}
else if( $position == 'footer' )
{
return $this->footerCode;
}
}
/**
* Get Ad Code
* This is really just a passthrough so we can extend
*
* @param string Key
*/
public function getAdCode( $key )
{
return $this->settings[ $key ];
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Advertisements
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 10914 $
*/
class IPSAdCode extends IPSAdCodeDefault
{
/**
* Constructor
*
*/
public function __construct( ipsRegistry $registry )
{
return parent::__construct( $registry );
}
/**
* Checks to see if the specified member group can view ads
*
* @access public
*
* @param integer $group_id Group to check
* @return bool
*/
public function userCanViewAds()
{
/* Check to see if the system is globally disabled */
if( ! ipsRegistry::$settings['ad_code_global_enabled'] )
{
return false;
}
/* Check to see if this member group can view ads */
if( ipsRegistry::$settings['ad_code_exempt_groups'] )
{
if( IPSMember::isInGroup( ipsRegistry::member()->fetchMemberData(), explode( ',', ipsRegistry::$settings['ad_code_exempt_groups'] ) ) )
{
return false;
}
}
return true;
}
/**
* Sets global advertising code for display
*
* @access public
*
* @param string $position header or footer
* @param string $code Key for code to be displayed at specified position
* @return @e void
*/
public function setGlobalCode( $position, $code )
{
$code = $this->settings[ $code ];
if( $position == 'header' )
{
$this->headerCode = $code;
}
else if( $position == 'footer' )
{
$this->footerCode = $code;
}
}
/**
* Retrieves global advertising code for display
*
* @access public
*
* @param string $position header or footer
* @param string $code Code to be displayed at specified position
* @return @e void
*/
public function getGobalCode( $position )
{
if( $position == 'header' )
{
return $this->headerCode;
}
else if( $position == 'footer' )
{
return $this->footerCode;
}
}
/**
* Get Ad Code
* This is really just a passthrough so we can extend
*
* @param string Key
*/
public function getAdCode( $key )
{
return $this->settings[ $key ];
}
}
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
<a href="http://www.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,183 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Reader
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 18th November 2011
* @version $Revision: 8644 $
*/
class classes_archive_reader
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/* Switch fields */
protected $fields = array();
/**
* Set current app
*/
private $_app = '';
/**
* Constructor
*
*/
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Check for class_forums */
if ( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
$this->registry->setClass( 'class_forums', new $classToLoad( $this->registry ) );
$this->registry->class_forums->forumsInit();
}
/* Load topic class */
if ( ! $this->registry->isClassLoaded('topics') )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
$this->registry->setClass( 'topics', new $classToLoad( $this->registry ) );
}
/* Language class */
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
/* Fetch engine class */
$this->settings['archive_engine'] = ( $this->settings['archive_engine'] ) ? $this->settings['archive_engine'] : 'sql';
/* Load up archive class */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/archive/reader/' . $this->settings['archive_engine'] . '.php', 'classes_archive_reader_' . $this->settings['archive_engine'] );
$this->engine = new $classToLoad();
$this->fields = $this->registry->topics->getPostTableFields();
}
/**
* Set the current application
* @param string $app
*/
public function setApp( $app )
{
$this->_app = $app;
}
/**
* Get the application
* @return string
*/
public function getApp()
{
return $this->_app;
}
/**
* Fetch a topic's post count
* @param int Topic ID
* @param array Masks [visible, hidden, sdelete]
* @return int
*/
public function getPostCount( $tid, $masks )
{
$masks = ( is_array( $masks ) ) ? $masks : array( $masks );
return $this->engine->getPostCount( $tid, $masks );
}
/**
* getPosts
* Fetches posts based on different critera
* @param array Filters (see below for specifics)
* @return array
*
* FILTERS:
* topicId Get posts matching the (array) topic ids, (int) topic ID
* forumId Get posts matching the (array) topic ids, (int) forum ID
* postId Get posts matching the (array) post ids, (int) post id
* memberData Set memberData (this->memberData is used otherwise)
* onlyViewable Set whether this member can view them or not. (default is true ) NOTE: Will not check to see if parent topic is viewable!
* onlyVisible Set whether to skip unapproved posts where permission allows (default is true)
* postType array of 'sdelete', 'visible', 'hidden', 'pdeleted' (if you specify these, permission checks are NOT performed)
* sortField Sort key (date, pid, etc)
* sortOrder asc/desc
* pidIsGreater Where PID is greater than x
* dateIsGreater Where DATE is greater than UNIX
* skipForumCheck Skips the forum ID IN list check to ensure you have access to view (good for when using perms elsewhere)
* parse Parses post content
* limit, offset Limit the amount of results in the returned query
* getCount fetch count without limit
*
*/
public function getPosts( $filters )
{
return $this->engine->getPosts( $filters );
}
/**
* Get fields
* @return array
*/
public function getFields()
{
return $this->registry->topics->getPostTableFields();
}
/**
* Fetches topic data
* @param array $data
*/
public function get( $data )
{
/* Clean up a bit */
$data['offset'] = intval( $data['offset'] );
$data['limit'] = intval( $data['limit'] );
return $this->engine->getData( $data );
}
/**
* Take an archive row and returned native friendly array
* @param array $post
* @return array
*/
public function archiveToNativeFields( $post )
{
return $this->registry->topics->archivePostToNativeFields( $post );
}
}
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
<a href="http://www.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,530 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Writer
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 8644 $
*/
class classes_archive_reader_sql extends classes_archive_reader
{
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Do we have a remote DB? */
if ( $this->settings['archive_remote_sql_database'] && $this->settings['archive_remote_sql_user'] )
{
if ( ! is_object( $this->registry->dbFunctions()->getDB('remoteArchive') ) )
{
$this->registry->dbFunctions()->setDB( 'mysql', 'remoteArchive', array( 'sql_database' => $this->settings['archive_remote_sql_database'],
'sql_user' => $this->settings['archive_remote_sql_user'],
'sql_pass' => $this->settings['archive_remote_sql_pass'],
'sql_host' => $this->settings['archive_remote_sql_host'],
'sql_charset' => $this->settings['archive_remote_sql_charset'],
'sql_tbl_prefix' => $this->settings['sql_tbl_prefix'],
'catchConnectionError' => true ) );
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
else
{
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
}
else
{
$this->remoteDB = $this->DB;
}
}
/**
* Fetch a topic's post count
* @param int Topic ID
* @param array Masks [visible, hidden, sdelete]
* @return int
*/
public function getPostCount( $tid, $masks )
{
/* Fetch replies */
$_queued = $this->registry->class_forums->fetchPostHiddenQuery( $masks, 'archive_' );
$posts = $this->remoteDB->buildAndFetch( array( 'select' => 'COUNT(*) as posts', 'from' => 'forums_archive_posts', 'where' => "archive_topic_id={$tid} and {$_queued}" ) );
return intval( $posts['posts'] );
}
/**
* getPosts
* Fetches posts based on different critera
* @param array Filters (see below for specifics)
* @return array
*
* FILTERS:
* topicId Get posts matching the (array) topic ids, (int) topic ID
* forumId Get posts matching the (array) forum ids, (int) forum ID
* notForumId Get posts NOT matching the (array) forum ids, (int) forum ID
* postId Get posts matching the (array) post ids, (int) post id
* memberData Set memberData (this->memberData is used otherwise)
* onlyViewable Set whether this member can view them or not. (default is true ) NOTE: Will not check to see if parent topic is viewable!
* onlyVisible Set whether to skip unapproved posts where permission allows (default is true)
* postType array of 'sdelete', 'visible', 'hidden', 'pdeleted' (if you specify these, permission checks are NOT performed)
* sortField Sort key (date, pid, etc)
* sortOrder asc/desc
* pidIsGreater Where PID is greater than x
* dateIsGreater Where DATE is greater than UNIX
* skipForumCheck Skips the forum ID IN list check to ensure you have access to view (good for when using perms elsewhere)
* parse Parses post content
* limit, offset Limit the amount of results in the returned query
* getCount fetch count without limit
* getCountOnly fetch count and return only
*
*/
public function getPosts( $filters )
{
/* init */
$filters = $this->_setPostFilters( $filters );
$limit = null;
$posts = array();
$where = array();
$memberData = ( ! empty( $filters['memberData'] ) && is_array( $filters['memberData'] ) ) ? $filters['memberData'] : $this->memberData;
/* Posts */
if ( ! empty( $filters['postId'] ) )
{
$filters['postId'] = ( ! is_array( $filters['postId'] ) ) ? array( $filters['postId'] ) : $filters['postId'];
$where[] = "p.archive_id IN (" . implode( ',',$filters['postId'] ) . ")";
}
/* Topics */
if ( ! empty( $filters['topicId'] ) )
{
$filters['topicId'] = ( ! is_array( $filters['topicId'] ) ) ? array( $filters['topicId'] ) : $filters['topicId'];
$where[] = "p.archive_topic_id IN (" . implode( ',',$filters['topicId'] ) . ")";
}
/* Author Ids */
if ( ! empty( $filters['authorId'] ) )
{
$filters['authorId'] = ( ! is_array( $filters['authorId'] ) ) ? array( $filters['authorId'] ) : $filters['authorId'];
$where[] = "p.archive_author_id IN (" . implode( ',',$filters['authorId'] ) . ")";
}
/* PID is greater */
if ( ! empty( $filters['pidIsGreater'] ) )
{
$where[] = "p.archive_id > " . intval( $filters['pidIsGreater'] );
}
/* PID is less */
if ( ! empty( $filters['pidIsLess'] ) )
{
$where[] = "p.archive_id < " . intval( $filters['pidIsLess'] );
}
/* Date is greater */
if ( ! empty( $filters['dateIsGreater'] ) )
{
$where[] = "p.archive_content_date > " . intval( $filters['dateIsGreater'] );
}
/* Forum Ids */
if ( ! empty( $filters['forumId'] ) )
{
$filters['forumId'] = ( ! is_array( $filters['forumId'] ) ) ? array( $filters['forumId'] ) : $filters['forumId'];
$where[] = "archive_forum_id IN (" . implode( ',', $filters['forumId'] ) . ")";
}
/* Not Forum Ids */
if ( ! empty( $filters['notForumId'] ) )
{
$filters['notForumId'] = ( ! is_array( $filters['notForumId'] ) ) ? array( $filters['notForumId'] ) : $filters['notForumId'];
$where[] = "archive_forum_id NOT IN (" . implode( ',', $filters['notForumId'] ) . ")";
}
/* Visible / specific filters */
if ( ! empty( $filters['postType'] ) && is_array( $filters['postType'] ) )
{
$where[] = $this->registry->class_forums->fetchPostHiddenQuery( $filters['postType'], 'p.archive_' );
}
else
{
if ( isset( $filters['onlyViewable'] ) && $filters['onlyViewable'] === true && empty( $filters['onlyVisible'] ) )
{
$_perms = array( 'visible' );
if ( $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( false ) )
{
$_perms[] = 'sdelete';
}
if ( $this->registry->getClass('class_forums')->canQueuePosts( false ) )
{
$_perms[] = 'hidden';
}
$where[] = $this->registry->class_forums->fetchPostHiddenQuery( $_perms, 'p.archive_' );
}
else
{
/* Show visible only */
$where[] = $this->registry->class_forums->fetchPostHiddenQuery( array( 'visible' ), 'p.archive_' );
}
}
/* Forum ID check? */
if ( ( isset( $filters['onlyViewable'] ) && $filters['onlyViewable'] === true ) && ( empty($filters['skipForumCheck']) OR $filters['skipForumCheck'] === false ) )
{
if ( empty( $filters['forumId'] ) && empty( $filters['notForumId'] ) )
{
$forumIds = $this->registry->class_forums->fetchSearchableForumIds( $memberData['member_id'] );
if ( ! count( $forumIds ) )
{
return $where;
}
$where[] = "archive_forum_id IN (" . implode( ",", $forumIds ) . ")";
}
}
/* Did we want a count also? */
if ( ! empty( $filters['getCount'] ) || ! empty( $filters['getCountOnly'] ) )
{
$count = $this->remoteDB->buildAndFetch( array( 'select' => 'COUNT(*) as posts',
'from' => 'forums_archive_posts p',
'where' => implode( ' AND ', $where ) ) );
$this->_countPosts = $count['posts'];
if ( $filters['getCountOnly'] )
{
return $this->_countPosts;
}
}
/* Offset, limit */
if ( isset( $filters['offset'] ) OR isset( $filters['limit'] ) )
{
if ( $filters['offset'] > 0 || $filters['limit'] > 0 )
{
$limit = array( intval( $filters['offset'] ), intval( $filters['limit'] ) );
}
}
/* Order */
if ( ! empty( $filters['sortField'] ) )
{
if ( strstr( $filters['sortField'], '.' ) )
{
$order = $filters['sortField'];
}
else
{
$order = 'p.' . $filters['sortField'];
}
if ( isset( $filters['sortOrder'] ) )
{
$order .= ' ' . $filters['sortOrder'];
}
}
/* Fetch them */
$this->remoteDB->build( array( 'select' => 'p.*, p.archive_ip_address as post_ip',
'from' => 'forums_archive_posts p',
'where' => implode( ' AND ', $where ),
'limit' => $limit ? $limit : '',
'order' => $order ? $order : 'p.archive_id asc' ) );
$o = $this->remoteDB->execute();
while( $post = $this->remoteDB->fetch( $o ) )
{
/* Post IP overrides member */
$post['ip_address'] = $post['post_ip'];
$post = $this->registry->topics->archivePostToNativeFields( $post );
$posts[ $post['pid'] ] = $post;
}
return $posts;
}
/**
* Write single entry to DB
* @param array INTS
*/
public function getData( $data=array() )
{
if ( ! $this->remoteDB )
{
return;
}
/* Init */
$topicData = $data['parentData'];
$forumData = $this->registry->getClass('class_forums')->getForumById( $topicData['forum_id'] );
$permissionData = $this->registry->getClass('topics')->getPermissionData();
$first = $data['offset'];
$end = $data['limit'];
$fields = $this->getFields();
/* Default - just see all visible posts */
$queued_query_bit = ' AND ' . $this->registry->class_forums->fetchPostHiddenQuery('visible', 'archive_');
/* Can we deal with hidden posts? */
if ( $this->registry->class_forums->canQueuePosts( $topicData['forum_id'] ) )
{
if ( $permissionData['softDeleteSee'] )
{
/* See queued and soft deleted */
$queued_query_bit = ' AND ' . $this->registry->class_forums->fetchPostHiddenQuery( array( 'visible', 'hidden', 'sdeleted' ), 'archive_' );
}
else
{
/* Otherwise, see queued and approved */
$queued_query_bit = ' AND ' . $this->registry->class_forums->fetchPostHiddenQuery( array( 'visible', 'hidden' ), 'archive_' );
}
}
else
{
/* We cannot see hidden posts */
if ( $permissionData['softDeleteSee'] )
{
/* See queued and soft deleted */
$queued_query_bit = ' AND ' . $this->registry->class_forums->fetchPostHiddenQuery( array('approved', 'sdeleted'), 'archive_' );
}
}
/* Set up */
/* Ignored Users */
$ignored_users = array();
foreach( $this->member->ignored_users as $_i )
{
if ( $_i['ignore_topics'] )
{
$ignored_users[] = $_i['ignore_ignore_id'];
}
}
/* Format */
$this->registry->getClass('topics')->setTopicData('adCodeSet' , false );
$this->registry->getClass('topics')->setTopicData('ignoredUsers', $ignored_users );
$posts = array();
$cached = array();
/* Get posts separately */
if ( IPSLib::isUsingRemoteArchiveDB() )
{
/* Get posts */
$this->remoteDB->build( array( 'select' => '*',
'from' => 'forums_archive_posts',
'where' => 'archive_topic_id='.$topicData['tid'] . $queued_query_bit,
'order' => $fields[ $data['sortKey'] ] . ' ' . $data['sortOrder'],
'limit' => array( $first, $end ) ) );
$ab = $this->remoteDB->execute();
$mids = array();
while( $p = $this->remoteDB->fetch( $ab ) )
{
$posts[ $p['archive_id'] ] = $p;
$mids[ $p['archive_author_id'] ] = $p['archive_author_id'];
}
if ( count( $posts ) )
{
/* Get cached posts */
$this->DB->build( array( 'select' => 'cache_content_id, cache_content',
'from' => 'content_cache_posts',
'where' => 'cache_content_id IN ('. implode( ',', array_keys( $posts ) ) . ')' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$cached[ $row['cache_content_id'] ] = $row['cache_content'];
}
/* Get members */
$members = IPSMember::load( $mids, 'all' );
foreach( $posts as $pid => $pdata )
{
$pdata['member_id'] = $pdata['archive_author_id'];
if ( $data['goNative'] )
{
$pdata = $this->archiveToNativeFields( $pdata );
}
if ( $pdata['author_id'] )
{
$members[ $pdata['author_id'] ]['cache_content_sig'] = $members[ $pdata['author_id'] ]['cache_content'];
unset( $members[ $pdata['author_id'] ]['cache_content'] );
$posts[ $pid ] = array_merge( $members[ $pdata['author_id'] ], $pdata );
}
else
{
$posts[ $pid ] = $pdata;
}
/* Cached */
if ( isset( $cached[ $pid ] ) )
{
$posts[ $pid ]['cache_content'] = $cached[ $pid ];
}
}
}
}
else
{
/* Joins */
$_post_joins = array( array( 'select' => 'm.member_id as mid,m.name,m.member_group_id,m.email,m.joined,m.posts, m.last_visit, m.last_activity,m.login_anonymous,m.title as member_title, m.warn_level, m.warn_lastwarn, m.members_display_name, m.members_seo_name, m.has_gallery, m.has_blog, m.members_bitoptions,m.mgroup_others',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=a.archive_author_id',
'type' => 'left' ),
array( 'select' => 'pp.*',
'from' => array( 'profile_portal' => 'pp' ),
'where' => 'm.member_id=pp.pp_member_id',
'type' => 'left' ) );
/* Cache? */
if ( IPSContentCache::isEnabled() )
{
if ( IPSContentCache::fetchSettingValue('post') )
{
$_post_joins[] = IPSContentCache::join( 'post', 'a.archive_id' );
}
if ( IPSContentCache::fetchSettingValue('sig') )
{
$_post_joins[] = IPSContentCache::join( 'sig' , 'm.member_id', 'ccb', 'left', 'ccb.cache_content as cache_content_sig, ccb.cache_updated as cache_updated_sig' );
}
}
/* Get posts */
$this->remoteDB->build( array( 'select' => 'a.*',
'from' => array( 'forums_archive_posts' => 'a' ),
'where' => 'archive_topic_id='.$topicData['tid'] . $queued_query_bit,
'order' => $fields[ $data['sortKey'] ] . ' ' . $data['sortOrder'],
'limit' => array( $first, $end ),
'add_join' => $_post_joins ) );
$oq = $this->remoteDB->execute();
while ( $row = $this->remoteDB->fetch( $oq ) )
{
$row['member_id'] = $row['archive_author_id'];
if ( $data['goNative'] )
{
$row = $this->archiveToNativeFields( $row );
}
$posts[ $row['pid'] ] = $row;
}
}
/* Return */
return $posts;
}
/**
* Set post filters
* Takes user input and cleans it up a bit
*
* @param array Incoming filters
* @return array
*/
protected function _setPostFilters( $filters )
{
$filters['sortOrder'] = ( isset( $filters['sortOrder'] ) ) ? $filters['sortOrder'] : '';
$filters['sortField'] = ( isset( $filters['sortField'] ) ) ? $filters['sortField'] : '';
$filters['offset'] = ( isset( $filters['offset'] ) ) ? $filters['offset'] : '';
$filters['limit'] = ( isset( $filters['limit'] ) ) ? $filters['limit'] : '';
$filters['isVisible'] = ( isset( $filters['isVisible'] ) ) ? $filters['isVisible'] : '';
switch( $filters['sortOrder'] )
{
default:
case 'desc':
case 'descending':
case 'z-a':
$filters['sortOrder'] = 'desc';
break;
case 'asc':
case 'ascending':
case 'a-z':
$filters['sortOrder'] = 'asc';
break;
}
/* Do some set up */
switch( $filters['sortField'] )
{
case 'date':
case 'time':
case 'post_date':
$filters['sortField'] = 'archive_content_date';
break;
case 'pid':
case 'id':
$filters['sortField'] = 'archive_id';
break;
}
/* Others */
$filters['offset'] = intval( $filters['offset'] );
$filters['limit'] = intval( $filters['limit'] );
$filters['unixCutOff'] = ( ! empty( $filters['unixCutOff'] ) ) ? intval( $filters['unixCutOff'] ) : 0;
/* So we don't have to do this twice */
$filters['_cleaned'] = true;
return $filters;
}
}
@@ -0,0 +1,416 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Reader
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 18th November 2011
* @version $Revision: 8644 $
*/
/**
* Restores topics that are either manually flagged or via settings
* from the Admin CP.
*
* Manually flagged topics are always restored first.
* @author matt
*
*/
class classes_archive_restore
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Set current app
*/
private $_app = '';
/**
* Constructor
*
*/
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Check for class_forums */
if ( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
$this->registry->setClass( 'class_forums', new $classToLoad( $this->registry ) );
$this->registry->class_forums->forumsInit();
}
/* Language class */
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
/* Fetch engine class */
$this->settings['archive_engine'] = ( $this->settings['archive_engine'] ) ? $this->settings['archive_engine'] : 'sql';
/* Load up archive class */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/archive/restore/' . $this->settings['archive_engine'] . '.php', 'classes_archive_restore_' . $this->settings['archive_engine'] );
$this->engine = new $classToLoad();
}
/**
* Set the current application
* @param string $app
*/
public function setApp( $app )
{
$this->_app = $app;
}
/**
* Get the application
* @return string
*/
public function getApp()
{
return $this->_app;
}
/**
* Restore posts to the topic
* @param array INTS
*/
public function restore( $pids=array() )
{
if ( ! count( $pids ) )
{
return null;
}
$topics = array();
$forumIds = array();
$completedTopics = array();
$workingTopics = array();
$maxes = array();
/* Load the attachments stuff */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$class_attach = new $classToLoad( $this->registry );
$class_attach->type = 'post';
$class_attach->init();
/* Load the attachments stuff */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/topics.php', 'app_forums_classes_topics' );
$topicClass = new $classToLoad( $this->registry );
/* Fetch data based on PIDs */
$posts = $topicClass->getPosts( array( 'postId' => $pids,
'sortField' => 'pid',
'sortOrder' => 'asc',
'isArchivedTopic' => true ) );
foreach( $posts as $pid => $post )
{
/* Write it */
$this->engine->set( $post );
/* Collect some data */
if ( ! in_array( $post['tid'], $topics ) )
{
$post['_pids'] = 1;
$post['_lowPid'] = $post['archive_id'];
$post['_maxPid'] = $post['archive_id'];
$post['_topicCount'] = ( intval( $post['posts'] ) + intval( $post['topic_deleted_posts'] ) + intval( $post['topic_queuedposts'] ) + 1 );
$topics[ $post['tid'] ] = $post;
}
else
{
$topics[ $post['tid'] ]['_maxPid'] = $post['archive_id'];
$topics[ $post['tid'] ]['_pids']++;
}
/* Collect fids */
$forums[ $post['forum_id'] ] = $post['forum_id'];
}
/* Get the maxes */
$this->DB->build( array( 'select' => 'topic_id, MAX(pid) as i',
'from' => 'posts',
'where' => 'topic_id IN (' . implode( ',', array_keys( $topics ) ) . ')',
'group' => 'topic_id' ) );
$o = $this->DB->execute();
while( $t = $this->DB->fetch( $o ) )
{
$maxes[ $t['topic_id'] ] = intval( $t['i'] );
}
/* Figure out how many topics have been completed */
foreach( $topics as $tid => $data )
{
/* First pid matches topic first pid, so we have the first post in the topic
* but have we got all the posts in this topic?
*/
if ( $maxes[ $tid ] == $data['_maxPid'] )
{
$completedTopics[] = $data['tid'];
}
else
{
$workingTopics[] = $data['tid'];
}
}
/* Update completed */
if ( count( $completedTopics ) )
{
$this->DB->update( 'topics', array( 'topic_archive_status' => $this->registry->class_forums->fetchTopicArchiveFlag( 'exclude' ) ), 'tid IN(' . implode( ',', $completedTopics ) . ')' );
/* Archive attachments */
$class_attach->bulkUnarchive( $completedTopics, 'attach_parent_id' );
/* Remove posts */
$this->engine->removePostsByTids( $completedTopics );
}
/* Flag as archived */
$this->engine->setAsRestoredByPids( $pids );
/* Do forums */
foreach( $forums as $id )
{
$this->registry->class_forums->forumRebuild( $id );
}
/* Log it */
$this->log( $pids, true );
}
/**
* Process a batch. Genius.
* $options is an array of keys and values:
* process - INT - number of items to process in this batch
* @return int count of topics archived
*/
public function processBatch( $options=array() )
{
$restoreData = $this->getRestoreData();
$topics = array();
$forums = array();
$pids = array();
/* Fix up options */
$options['process'] = ( is_numeric( $options['process'] ) && $options['process'] > 0 ) ? $options['process'] : 250;
if ( ! $restoreData['restore_min_tid'] && ! $restoreData['restore_max_tid'] && ! count( $restoreData['restore_manual_tids'] ) )
{
return false;
}
/* Any manually flagged? */
if ( count( $restoreData['restore_manual_tids'] ) )
{
/* Select remaining Pids */
$pids = $this->engine->getPidsInTids( IPSLib::cleanIntArray( array_keys( $restoreData['restore_manual_tids'] ) ), $options['process'] );
/* Did we complete topics? */
foreach( $restoreData['restore_manual_tids'] as $tid => $maxPid )
{
if ( in_array( $maxPid, array_keys( $pids ) ) )
{
$this->deleteManualId( $tid );
}
}
/* All done? */
if ( ! count( $pids ) )
{
$restoreData['restore_manual_tids'] = array();
$this->setRestoreData( $restoreData );
}
/* Update process for below */
$options['process'] -= count( $pids );
}
/* Now fetch the max/min if archiver is on */
if ( $this->settings['archive_on'] && $options['process'] > 0 && $restoreData['restore_min_tid'] && $restoreData['restore_max_tid'] )
{
$date = IPS_UNIX_TIME_NOW - ( 86400 * intval( $this->settings['archive_restore_days'] ) );
$pids = $this->engine->getPidsBetweenTidsAndDate( $restoreData['restore_min_tid'], $restoreData['restore_max_tid'], $date, $options['process'] );
/* All done? */
if ( ! count( $pids ) )
{
$restoreData['restore_min_tid'] = 0;
$restoreData['restore_max_tid'] = 0;
$this->setRestoreData( $restoreData );
}
}
/* Process */
$this->restore( $pids );
return count( $pids );
}
/**
* Flag an item for manual unarchive
* @param int $id
*/
public function setManualUnarchive( $id )
{
/* Init */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
$topicClass = new $classToLoad( $this->registry );
$topic = $topicClass->getTopicById( $id );
if ( $topic['tid'] && $this->registry->class_forums->fetchArchiveTopicType( $topic ) == 'archived' )
{
$topicClass->updateTopic( $topic['tid'], array( 'topic_archive_status' => $this->registry->class_forums->fetchTopicArchiveFlag('restore') ) );
$this->insertManualId( $id );
}
}
/**
* Add an ID to the manual restore filter
*/
public function insertManualId( $id )
{
$data = $this->getRestoreData();
$max = $this->engine->getMaxPidInTid( $id );
$data['restore_manual_tids'][ $id ] = $max;
$this->setRestoreData( $data );
}
/**
* Delete an ID from the manual restore filter
*/
public function deleteManualId( $id )
{
$data = $this->getRestoreData();
if ( in_array( $id, array_keys( $data['restore_manual_tids'] ) ) )
{
unset( $data['restore_manual_tids'][ $id ] );
$this->setRestoreData( $data );
}
}
/**
* Get restore data
*/
public function getRestoreData()
{
$data = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'core_archive_restore' ) );
if ( IPSLib::isSerialized( $data['restore_manual_tids'] ) )
{
$data['restore_manual_tids'] = unserialize( $data['restore_manual_tids'] );
}
else
{
$data['restore_manual_tids'] = array();
}
return $data;
}
/**
* Set restore data
* @param array
*/
public function setRestoreData( $data )
{
if ( is_array( $data['restore_manual_tids'] ) )
{
$data['restore_manual_tids'] = serialize( $data['restore_manual_tids'] );
}
$data['restore_min_tid'] = intval( $data['restore_min_tid'] );
$data['restore_max_tid'] = intval( $data['restore_max_tid'] );
$this->DB->delete( 'core_archive_restore');
$this->DB->insert( 'core_archive_restore', $data );
}
/**
* Take an archive row and returned native friendly array
* @param array $post
* @return array
*/
public function archiveToNativeFields( $post )
{
$native = array( 'pid' => intval( $post['archive_id'] ),
'author_id' => intval( $post['archive_author_id'] ),
'author_name' => $post['archive_author_name'],
'ip_address' => $post['archive_ip_address'],
'post_date' => intval( $post['archive_content_date'] ),
'post' => $post['archive_content'],
'queued' => $post['archive_queued'],
'topic_id' => intval( $post['archive_topic_id'] ),
'new_topic' => intval( $post['archive_is_first'] ),
'post_bwoptions' => $post['archive_bwoptions'],
'post_key' => $post['archive_attach_key'],
'post_htmlstate' => $post['archive_html_mode'],
'use_sig' => $post['archive_show_signature'],
'use_emo' => $post['archive_show_emoticons'],
'append_edit' => $post['archive_show_edited_by'],
'edit_time' => $post['archive_edit_time'],
'edit_name' => $post['archive_edit_name'],
'post_edit_reason' => $post['archive_edit_reason'] );
return $native;
}
/**
* Logs archive action
* @param array $ids
*/
public function log( $ids )
{
$this->DB->insert( 'core_archive_log', array( 'archlog_date' => IPS_UNIX_TIME_NOW,
'archlog_app' => $this->getApp(),
'archlog_ids' => serialize( $ids ),
'archlog_is_restore' => 1,
'archlog_count' => count( $ids ) ) );
}
}
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
<a href="http://www.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,175 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Restore
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 8644 $
*/
class classes_archive_restore_sql extends classes_archive_restore
{
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Do we have a remote DB? */
if ( $this->settings['archive_remote_sql_database'] && $this->settings['archive_remote_sql_user'] )
{
if ( ! is_object( $this->registry->dbFunctions()->getDB('remoteArchive') ) )
{
$this->registry->dbFunctions()->setDB( 'mysql', 'remoteArchive', array( 'sql_database' => $this->settings['archive_remote_sql_database'],
'sql_user' => $this->settings['archive_remote_sql_user'],
'sql_pass' => $this->settings['archive_remote_sql_pass'],
'sql_host' => $this->settings['archive_remote_sql_host'],
'sql_charset' => $this->settings['archive_remote_sql_charset'],
'sql_tbl_prefix' => $this->settings['sql_tbl_prefix'],
'catchConnectionError' => true ) );
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
else
{
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
}
else
{
$this->remoteDB = $this->DB;
}
}
/**
* Get max PID in a TID
*/
public function getMaxPidInTid( $tid )
{
$max = $this->remoteDB->buildAndFetch( array( 'select' => 'MAX(archive_id) as i', 'from' => 'forums_archive_posts', 'where' => 'archive_topic_id=' . intval( $tid ) ) );
return $max['i'];
}
/**
* Fetch by TIDS
*/
public function getPidsInTids( array $tids, $limit=50 )
{
$pids = array();
/* Select remaining Pids */
$this->remoteDB->build( array( 'select' => 'archive_id',
'from' => 'forums_archive_posts',
'where' => 'archive_topic_id IN(' . implode( ',', $tids ) . ') AND archive_restored=0',
'order' => 'archive_topic_id ASC, archive_id ASC',
'limit' => array( 0, $limit ) ) );
$o = $this->remoteDB->execute();
while( $post = $this->remoteDB->fetch( $o ) )
{
$pids[ $post['archive_id'] ] = $post['archive_id'];
}
return $pids;
}
/**
* Fetch between TIDS and date
*
*/
public function getPidsBetweenTidsAndDate( $min, $max, $date=0, $limit=50 )
{
$this->remoteDB->build( array( 'select' => 'archive_id',
'from' => 'forums_archive_posts',
'where' => 'archive_content_date > ' . $date . ' AND archive_topic_id BETWEEN ' . intval( $min ) . ' AND ' . intval( $max ),
'order' => 'archive_topic_id ASC, archive_id ASC',
'limit' => array( 0, $limit ) ) );
$o = $this->remoteDB->execute();
while( $post = $this->remoteDB->fetch( $o ) )
{
$pids[ $post['archive_id'] ] = $post['archive_id'];
}
return $pids;
}
/**
* Remove posts by TIDs
* @param array TIDS
*/
public function removePostsByTids( array $tids )
{
if ( count( $tids ) )
{
$this->remoteDB->delete( 'forums_archive_posts', 'archive_topic_id IN(' . implode( ',', $tids ) . ')' );
}
}
/**
* Remove posts by PIDs
* @param array PIDs
*/
public function setAsRestoredByPids( array $pids )
{
if ( count( $pids ) )
{
$this->DB->update( 'forums_archive_posts', array( 'archive_restored' => 1 ), 'archive_id IN (' . implode( ',', $pids ) .')' );
}
}
/**
* Write single entry to DB
* @param array INTS
*/
public function set( $data=array() )
{
if ( ! count( $data ) )
{
return null;
}
$this->DB->replace( 'posts', $this->archiveToNativeFields( $data ), array( 'pid' ) );
}
}
@@ -0,0 +1,691 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Writer
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 8644 $
*/
class classes_archive_writer
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Set current app
*/
private $_app = '';
/**
* Archive 'do' allowed fields
*/
private $_archiveOnFields = array( 'state' => 'state',
'pinned' => 'pinned',
'approved' => 'approved',
'poll' => 'poll_state',
'post' => 'posts',
'view' => 'views',
'rating' => 'topic_rating_total',
'forum' => 'forum_id',
'member' => 'starter_id',
'lastpost' => 'last_post' );
/**
* Archive 'skip' allowed fields
*/
private $_archiveSkipFields = array( 'post' => 'posts',
'view' => 'views',
'rating' => 'topic_rating_total',
'forum' => 'forum_id',
'member' => 'starter_id',
'lastpost' => 'last_post');
/**
* Constructor
*
*/
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Check for class_forums */
if ( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
$this->registry->setClass( 'class_forums', new $classToLoad( $this->registry ) );
$this->registry->class_forums->forumsInit();
}
/* Language class */
$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
/* Fetch engine class */
$this->settings['archive_engine'] = ( $this->settings['archive_engine'] ) ? $this->settings['archive_engine'] : 'sql';
/* Load up archive class */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/archive/writer/' . $this->settings['archive_engine'] . '.php', 'classes_archive_writer_' . $this->settings['archive_engine'] );
$this->engine = new $classToLoad();
if ( $this->engine->test() !== true )
{
$this->error( $this->lang->words['archive_fail_engine'] );
}
}
/**
* It's magic!
* @param string $method
* @param array $arguments
*/
public function __call( $method, $arguments )
{
switch ( $method )
{
case 'testConnection':
return $this->engine->test();
break;
case 'createTable':
return $this->engine->createTable();
break;
case 'flush':
return $this->engine->flush();
break;
}
}
/**
* Updates posts
*
* @param $what Array of fields with vals to update
* @param $where String of what to update
*/
public function update( array $what, $where )
{
return $this->engine->update( $what, $where );
}
/**
* Set the current application
* @param string $app
*/
public function setApp( $app )
{
$this->_app = $app;
}
/**
* Get the application
* @return string
*/
public function getApp()
{
return $this->_app;
}
/**
* Return archive on fields
* @return array
*/
public function getArchiveOnFields()
{
return array_keys( $this->_archiveOnFields );
}
/**
* Return archive skip fields
* @return array
*/
public function getArchiveSkipFields()
{
return array_keys( $this->_archiveSkipFields );
}
/**
* Write topics to the archive
* @param array INTS
*/
public function write( $pids=array() )
{
if ( ! count( $pids ) )
{
return null;
}
$topics = array();
$forumIds = array();
$completedTopics = array();
$workingTopics = array();
$maxes = array();
/* Load the attachments stuff */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$class_attach = new $classToLoad( $this->registry );
$class_attach->type = 'post';
$class_attach->init();
/* Fetch data based on PIDs */
$this->DB->build( array( 'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid IN (' . implode( ',', $pids ) . ')',
'order' => 'p.topic_id ASC, p.pid ASC',
'add_join' => array( array( 'select' => 't.*',
'from' => array( 'topics' => 't' ),
'where' => 'p.topic_id=t.tid' ) ) ) );
$o = $this->DB->execute();
while( $post = $this->DB->fetch( $o ) )
{
/* Write it */
$this->engine->set( $post );
/* Collect some data */
if ( ! in_array( $post['tid'], $topics ) )
{
$post['_pids'] = 1;
$post['_lowPid'] = $post['pid'];
$post['_maxPid'] = $post['pid'];
$post['_topicCount'] = ( intval( $post['posts'] ) + intval( $post['topic_deleted_posts'] ) + intval( $post['topic_queuedposts'] ) + 1 );
$topics[ $post['tid'] ] = $post;
}
else
{
$topics[ $post['tid'] ]['_maxPid'] = $post['pid'];
$topics[ $post['tid'] ]['_pids']++;
}
/* Collect fids */
$forums[ $post['forum_id'] ] = $post['forum_id'];
}
/* Got any topics? */
if ( ! count( $topics ) )
{
return;
}
/* Get the maxes */
$this->DB->build( array( 'select' => 'topic_id, MAX(pid) as i',
'from' => 'posts',
'where' => 'topic_id IN (' . implode( ',', array_keys( $topics ) ) . ')',
'group' => 'topic_id' ) );
$o = $this->DB->execute();
while( $t = $this->DB->fetch( $o ) )
{
$maxes[ $t['topic_id'] ] = intval( $t['i'] );
}
/* Figure out how many topics have been completed */
foreach( $topics as $tid => $data )
{
/* First pid matches topic first pid, so we have the first post in the topic
* but have we got all the posts in this topic?
*/
if ( $maxes[ $tid ] == $data['_maxPid'] )
{
$completedTopics[] = $data['tid'];
}
else
{
$workingTopics[] = $data['tid'];
}
}
/* Update working */
if ( count( $workingTopics ) )
{
$this->DB->update( 'topics', array( 'topic_archive_status' => $this->registry->class_forums->fetchTopicArchiveFlag( 'working' ) ),'tid IN(' . implode( ',', $workingTopics ) . ')' );
}
/* Update completed */
if ( count( $completedTopics ) )
{
$this->DB->update( 'topics', array( 'topic_archive_status' => $this->registry->class_forums->fetchTopicArchiveFlag( 'archived' ) ), 'tid IN(' . implode( ',', $completedTopics ) . ')' );
/* Archive attachments */
$class_attach->bulkArchive( $completedTopics, 'attach_parent_id' );
/* Remove posts */
$this->DB->delete( 'posts', 'topic_id IN(' . implode( ',', $completedTopics ) . ')' );
}
/* Do forums */
foreach( $forums as $id )
{
$this->registry->class_forums->forumRebuild( $id );
}
/* Log it */
$this->log( $pids );
}
/**
* Process a batch. Genius.
* $options is an array of keys and values:
* process - INT - number of items to process in this batch
* @return int count of topics archived
*/
public function processBatch( $options=array() )
{
/* Archiver running? */
if ( ! $this->settings['archive_on'] )
{
return false;
}
/* Init vars */
$query = $this->getArchiveWhereQuery();
$topics = array();
$forums = array();
$pids = array();
/* Fix up options */
$options['process'] = ( is_numeric( $options['process'] ) && $options['process'] > 0 ) ? $options['process'] : 250;
if ( $query === null )
{
return null;
}
/* First see if we have a topic in progress */
$working = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'topics',
'where' => 'topic_archive_status=' . $this->registry->class_forums->fetchTopicArchiveFlag( 'working' ),
'order' => 'tid ASC',
'limit' => array( 0, 1 ) ) );
/* Got one? */
if ( $working['tid'] )
{
$doneSoFar = $this->engine->getDoneSoFarByTid( $working['tid'] );
$postTable = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MAX(pid) as max',
'from' => 'posts',
'where' => 'pid > ' . intval( $doneSoFar['max'] ) . ' AND topic_id=' . $working['tid'] ) );
/* Select remaining Pids */
$this->DB->build( array( 'select' => 'pid',
'from' => 'posts',
'where' => 'pid > ' . intval( $doneSoFar['max'] ) . ' AND topic_id=' . $working['tid'],
'order' => 'pid ASC',
'limit' => array( 0, $options['process'] ) ) );
$o = $this->DB->execute();
while( $post = $this->DB->fetch( $o ) )
{
$pids[ $post['pid'] ] = $post['pid'];
}
/* Update process for below */
$options['process'] -= count( $pids );
}
/* Carry on? */
if ( $options['process'] > 0 )
{
/* Collect topic IDs first */
$this->DB->build( array( 'select' => '*',
'from' => 'topics',
'where' => $query . ' AND (posts + topic_deleted_posts + topic_queuedposts ) >= 0',
/**
* We can't check for posts > 0 because if the topic has only the first post it will skip them
*
* @link http://community.invisionpower.com/tracker/issue-37131-archive-posts-missing-old-topics-with-post-count-0/
*/
//'where' => $query . ' AND (posts + topic_deleted_posts + topic_queuedposts ) > 0',
'order' => 'tid ASC',
'limit' => array( 0, 250 ) ) );
$o = $this->DB->execute();
$counter = 0;
while( $topic = $this->DB->fetch( $o ) )
{
$topics[] = $topic['tid'];
$counter += ( $topic['posts'] + $topic['topic_deleted_posts'] + $topic['topic_queuedposts'] ) + 1;
if ( $counter >= $options['process'] )
{
break;
}
}
/* Got anything? */
if ( ! count( $topics ) )
{
return 0;
}
/* Now fetch the PIDS */
$this->DB->build( array( 'select' => 'pid',
'from' => 'posts',
'where' => 'topic_id IN (' . implode( ',', $topics ) . ')',
'order' => 'topic_id ASC, pid ASC',
'limit' => array( 0, $options['process'] ) ) );
$o = $this->DB->execute();
while( $post = $this->DB->fetch( $o ) )
{
$pids[ $post['pid'] ] = $post['pid'];
}
}
/* Process */
$this->write( $pids );
return count( $pids );
}
/**
* Give me a key and I'll give you a DB field you lucky beasts
* @param string $key
*/
public function getDbFieldFromKey( $key )
{
return ( isset( $this->_archiveOnFields[ $key ] ) ) ? $this->_archiveOnFields[ $key ] : null;
}
/**
* Get a count of how many topics the current settings would archive off
* if performed in one go
* @param array $rules [Optional]
* @return array array( count, total, percentage )
*/
public function getArchivePossibleCount( $rules=array() )
{
$query = $this->getArchiveWhereQuery( $rules, false, true );
$return = array( 'count' => null, 'percentage' => 0, 'total' => 0 );
if ( $query !== null )
{
$total = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count',
'from' => 'topics',
'where' => $query . ' AND state != \'link\'' ) );
$all = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count',
'from' => 'topics' ) );
$return['count'] = intval( $total['count'] );
$return['total'] = intval( $all['count'] );
if ( $return['count'] && $return['total'] )
{
$return['percentage'] = round( ( $return['count'] / $return['total'] ) * 100, 2 );
}
}
return $return;
}
/**
* Returns the WHERE portion of a query string required to fetch topics to archive
* @param array $rules [Optional]
*/
public function getArchiveWhereQuery( $rules=array(), $onlyGetUnarchived=true, $excludeExcluded=false )
{
$where = ( $onlyGetUnarchived ) ? array( 'topic_archive_status=' . $this->registry->class_forums->fetchTopicArchiveFlag( 'not' ) ) : array();
$whereNot = ( $excludeExcluded ) ? array( 'topic_archive_status=' . $this->registry->class_forums->fetchTopicArchiveFlag( 'exclude' ) ) : array();
/* If no input, fetch from deebee */
if ( ! count( $rules ) )
{
$rules = $this->getRulesFromDb();
}
/* Hello mum! */
if ( is_array( $rules ) && count( $rules ) )
{
if ( is_array( $rules['archive'] ) )
{
foreach( $rules['archive'] as $key => $data )
{
$result = $this->_buildQueryBit( $key, $data, true );
if ( $result !== null )
{
$where[] = $result;
}
}
}
if ( is_array( $rules['skip'] ) )
{
foreach( $rules['skip'] as $key => $data )
{
$result = $this->_buildQueryBit( $key, $data, false );
if ( $result !== null )
{
$where[] = $result;
}
}
}
}
foreach ( $whereNot as $w )
{
$where[] = "!({$w})";
}
if ( count( $where ) )
{
/* Only fetch non-deleted topics */
$where[] = $this->registry->class_forums->fetchTopicHiddenQuery( array( 'hidden', 'visible' ) );
return implode( ' AND ', $where );
}
else
{
return null;
}
}
/**
* Fetch the rules form the database
*/
public function getRulesFromDb()
{
$rules = array();
$this->DB->build( array( 'select' => '*',
'from' => 'core_archive_rules',
'where' => 'archive_app=\'' . $this->DB->addSlashes( $this->getApp() ) . '\'' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$whut = ( $row['archive_skip'] ) ? 'skip' : 'archive';
$rules[ $whut ][ $row['archive_field'] ] = array( 'value' => $row['archive_value'],
'text' => $row['archive_text'],
'unit' => $row['archive_unit'] );
}
return $rules;
}
/**
* Take a post and returned archive friendly array
* @param array $post
* @return array
*/
public function nativeToArchiveFields( $post )
{
$archive = array( 'archive_id' => intval( $post['pid'] ),
'archive_author_id' => intval( $post['author_id'] ),
'archive_author_name' => $post['author_name'],
'archive_ip_address' => $post['ip_address'],
'archive_content_date' => intval( $post['post_date'] ),
'archive_content' => $post['post'],
'archive_queued' => $post['queued'],
'archive_topic_id' => intval( $post['topic_id'] ),
'archive_is_first' => intval( $post['new_topic'] ),
'archive_bwoptions' => $post['post_bwoptions'],
'archive_added' => IPS_UNIX_TIME_NOW,
'archive_attach_key' => $post['post_key'],
'archive_html_mode' => $post['post_htmlstate'],
'archive_show_signature' => $post['use_sig'],
'archive_show_emoticons' => $post['use_emo'],
'archive_show_edited_by' => $post['append_edit'],
'archive_edit_time' => intval( $post['edit_time'] ),
'archive_edit_name' => $post['edit_name'],
'archive_edit_reason' => $post['post_edit_reason'],
'archive_forum_id' => intval( $post['forum_id'] ) );
return $archive;
}
/**
* Logs archive action
* @param array $ids
*/
public function log( $ids )
{
$this->DB->insert( 'core_archive_log', array( 'archlog_date' => IPS_UNIX_TIME_NOW,
'archlog_app' => $this->getApp(),
'archlog_ids' => serialize( $ids ),
'archlog_is_restore' => 0,
'archlog_count' => count( $ids ) ) );
}
/**
* Logs archive action
* @param array $ids
* @param boolean $isRestore
*/
public function error( $msg )
{
$this->DB->insert( 'core_archive_log', array( 'archlog_date' => IPS_UNIX_TIME_NOW,
'archlog_app' => $this->getApp(),
'archlog_msg' => $msg,
'archlog_is_error' => 1 ) );
}
/**
* Build a WHERE segment
* @param string $key
* @param data $data
* @param boolean $archiveOn Archive = true, skip = false
*/
protected function _buildQueryBit( $key, $data, $archiveOn )
{
$strOp = ( $archiveOn ) ? '=' : '!=';
$inOp = ( $archiveOn ) ? 'IN' : 'NOT IN';
switch( $key )
{
case 'state':
if ( $data['value'] != '' && $data['value'] != '-' )
{
return $this->getDbFieldFromKey( $key ) . $strOp . "'" . $data['value'] . "'";
}
break;
case 'pinned':
case 'approved':
case 'poll':
if ( $data['value'] != '' && $data['value'] != '-' )
{
return $this->getDbFieldFromKey( $key ) . $strOp . intval( $data['value'] );
}
break;
case 'post':
case 'view':
case 'rating':
if ( is_numeric( $data['text'] ) && $data['text'] > 0 )
{
return $this->getDbFieldFromKey( $key ) . $data['value'] . intval( $data['text'] );
}
break;
case 'lastpost':
if ( is_numeric( $data['text'] ) && $data['text'] > 0 )
{
switch( $data['unit'] )
{
case 'd':
$seconds = 86400;
break;
case 'm':
$seconds = 2592000;
break;
case 'y':
$seconds = 31536000;
break;
}
$time = IPS_UNIX_TIME_NOW - ( $seconds * intval( $data['text'] ) );
/* Switch around for skipping */
$data['value'] = ( $archiveOn ) ? $data['value'] : ( $data['value'] == '>' ? '<' : '>' );
return $this->getDbFieldFromKey( $key ) . ' ' . $data['value'] . ' ' . $time;
}
break;
case 'forum':
case 'member':
if ( $data['text'] )
{
if ( IPSLib::isSerialized( $data['text'] ) )
{
$ids = unserialize( $data['text'] );
}
else
{
$ids = array();
}
$inOp = ( $data['value'] == '+' ) ? 'IN' : 'NOT IN';
if ( is_array( $ids ) && count( $ids ) )
{
return $this->getDbFieldFromKey( $key ) . ' ' . $inOp . '(' . implode(',', $ids ) . ')';
}
}
break;
}
return null;
}
}
@@ -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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,188 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Archive: Writer
* By Matt Mecham
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 8644 $
*/
class classes_archive_writer_sql extends classes_archive_writer
{
protected $remoteDB = false;
protected $connectError = false;
public function __construct()
{
/* Make registry objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Connect */
$this->_connect();
}
/**
* Connect to DB
*/
protected function _connect( $forceNew=false )
{
/* Do we have a remote DB? */
if ( $this->settings['archive_remote_sql_database'] && $this->settings['archive_remote_sql_user'] )
{
if ( $forceNew OR ! is_object( $this->registry->dbFunctions()->getDB('remoteArchive') ) )
{
$this->registry->dbFunctions()->setDB( 'mysql', 'remoteArchive', array( 'sql_database' => $this->settings['archive_remote_sql_database'],
'sql_user' => $this->settings['archive_remote_sql_user'],
'sql_pass' => $this->settings['archive_remote_sql_pass'],
'sql_host' => $this->settings['archive_remote_sql_host'],
'sql_charset' => $this->settings['archive_remote_sql_charset'],
'sql_tbl_prefix' => $this->settings['sql_tbl_prefix'],
'catchConnectionError' => true ) );
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
else
{
$this->remoteDB = $this->registry->dbFunctions()->getDB('remoteArchive');
/* Check for connection issue */
if ( $this->remoteDB->error )
{
$this->connectError = $this->remoteDB->error;
$this->remoteDB = null;
$this->registry->dbFunctions()->unsetDB('remoteArchive');
}
}
}
else
{
$this->remoteDB = $this->DB;
}
}
/**
* Flush and reconnect
*/
public function flush()
{
$this->registry->dbFunctions()->unsetDB('remoteArchive');
$this->_connect( TRUE );
}
/**
* Test to ensure this works
*/
public function test()
{
if ( $this->connectError )
{
return $this->connectError;
}
if ( ! $this->remoteDB )
{
return 'NO_CONNECTION';
}
if ( ! $this->remoteDB->checkForTable( 'forums_archive_posts' ) )
{
return 'NO_TABLE';
}
return true;
}
/**
* Create the table
*/
public function createTable()
{
if ( ! $this->remoteDB->checkForTable( 'forums_archive_posts' ) )
{
/* Fetch correct file */
$TABLE = array();
$prefix = ( is_object( $this->registry->dbFunctions()->getDB('remoteArchive') ) ) ? $this->registry->dbFunctions()->getPrefix('remoteArchive') : $this->registry->dbFunctions()->getPrefix();
include( IPSLib::getAppDir('forums') . '/setup/versions/install/sql/forums_mysql_tables.php' );/*noLibHook*/
foreach( $TABLE as $t )
{
if ( stristr( $t, ' forums_archive_posts' ) )
{
$this->remoteDB->query( str_replace( ' forums_archive_posts', ' ' . $prefix . 'forums_archive_posts', $t ) );
}
}
}
}
/**
* Update posts
*
* @param $what Array of fields with vals to update
* @param $where String of what to update
*/
public function update( array $what, $where )
{
$this->remoteDB->update( 'forums_archive_posts', $what, $where );
}
/**
* Get counts
*
*/
public function getDoneSoFarByTid( $tid )
{
return $this->remoteDB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MAX(archive_id) as max',
'from' => 'forums_archive_posts',
'where' => 'archive_topic_id=' . $tid ) );
}
/**
* Write single entry to DB
* @param array INTS
*/
public function set( $data=array() )
{
if ( ! count( $data ) )
{
return null;
}
if ( ! $this->remoteDB )
{
return null;
}
$this->remoteDB->replace( 'forums_archive_posts', $this->nativeToArchiveFields( $data ), array( 'archive_id' ) );
}
}
File diff suppressed because it is too large. Load diff
+138 -166
View File
@@ -1,167 +1,139 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Content custom bbcode
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Content
* @link http://hatynka.in
* @version $Rev: 8644 $
*/
if( !class_exists('bbcode_parent_class') )
{
require_once( IPS_ROOT_PATH . 'sources/classes/bbcode/custom/defaults.php' );/*noLibHook*/
}
class bbcode_page extends bbcode_parent_class implements bbcodePlugin
{
/**
* Constructor
*
* @access public
* @param object Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
$this->currentBbcode = 'page';
parent::__construct( $registry );
}
/**
* Method that is run before the content is stored in the database
* You are responsible for ensuring you mark the replaced text appropriately so that you
* are able to unparse it, if you wish to have bbcode parsed on save
*
* @access public
* @param string $txt BBCode text from submission to be stored in database
* @return string Formatted content, ready for display
*/
public function preDbParse( $txt )
{
return parent::preDbParse( $txt );
}
/**
* Method that is run before the content is displayed to the user
* This is the safest method of parsing, as the original submitted text is left in tact.
* No markers are necessary if you use parse on display.
*
* @access public
* @param string $txt BBCode/parsed text from database to be displayed
* @return string Formatted content, ready for display
*/
public function preDisplayParse( $txt )
{
return parent::preDisplayParse( $txt );
}
/**
* Do the actual replacement
*
* @access protected
* @param string $txt Parsed text from database to be edited
* @return string BBCode content, ready for editing
*/
protected function _replaceText( $txt )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$tag = '[' . $this->currentBbcode . ']';
$_curPage = $this->request['pg'] ? $this->request['pg'] : 1;
$_ttlPages = 1;
$_ttlPages += substr_count( $txt, $tag );
$_requestUri = rtrim( $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI'), '/' );
$_reconstructed = ( ( $_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off' ) ? "https://" : "http://" ) . str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) . ( substr( $_requestUri, 0, 1 ) == '/' ? $_requestUri : '/' . $_requestUri );
//-----------------------------------------
// Get rid of existing pg= params
//-----------------------------------------
$_reconstructed = preg_replace( "/pg=(\d+)/", '', $_reconstructed );
$_reconstructed = rtrim($_reconstructed, '?&' );
$_reconstructed = str_replace( '&', '&amp;', $_reconstructed );
//-----------------------------------------
// Add on the parameter separator
//-----------------------------------------
if( $this->settings['url_type'] == 'query_string' )
{
if( substr_count( $_reconstructed, '?' ) > 1 )
{
$_reconstructed .= '&amp;';
}
else
{
$_reconstructed .= '?';
}
}
else
{
if( strpos( $_reconstructed, '?' ) !== false )
{
$_reconstructed .= '&amp;';
}
else
{
$_reconstructed .= '?';
}
}
//-----------------------------------------
// If no pages, no need to have links
//-----------------------------------------
if( $_ttlPages < 2 )
{
return $txt;
}
//-----------------------------------------
// Do replacements
//-----------------------------------------
if( !$_curPage )
{
$txt = substr( $txt, 0, strpos( $txt, $tag ) );
}
else
{
$bits = explode( $tag, $txt );
$txt = $bits[ $_curPage - 1 ];
}
//-----------------------------------------
// Clean up leading <br /> tags
//-----------------------------------------
$txt = trim($txt);
if( substr( $txt, 0, 15 ) == '~~~~~_____~~~~~' )
{
$txt = substr( $txt, 15 );
}
//-----------------------------------------
// And start generating output
//-----------------------------------------
$txt .= $this->registry->output->getTemplate('ccs_global')->articlePages( $_ttlPages, $_curPage, $_reconstructed );
return $txt;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* IP.Content custom bbcode
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Content
* @link http://www.invisionpower.com
* @version $Rev: 10914 $
*/
if( !class_exists('bbcode_parent_class') )
{
require_once( IPS_ROOT_PATH . 'sources/classes/bbcode/custom/defaults.php' );/*noLibHook*/
}
class bbcode_page extends bbcode_parent_class implements bbcodePlugin
{
/**
* Constructor
*
* @access public
* @param object Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
$this->currentBbcode = 'page';
parent::__construct( $registry );
}
/**
* Do the actual replacement
*
* @access protected
* @param string $txt Parsed text from database to be edited
* @return string BBCode content, ready for editing
*/
protected function _replaceText( $txt )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$tag = '[' . $this->currentBbcode . ']';
$_curPage = $this->request['pg'] ? $this->request['pg'] : 1;
$_ttlPages = 1;
$_ttlPages += substr_count( $txt, $tag );
$_requestUri = rtrim( $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI'), '/' );
$_reconstructed = ( ( $_SERVER['HTTPS'] and $_SERVER['HTTPS'] != 'off' ) ? "https://" : "http://" ) . $_SERVER['HTTP_HOST'] . ( substr( $_requestUri, 0, 1 ) == '/' ? $_requestUri : '/' . $_requestUri );
//-----------------------------------------
// Get rid of existing pg= params
//-----------------------------------------
$_reconstructed = preg_replace( "/pg=(\d+)/", '', $_reconstructed );
$_reconstructed = rtrim($_reconstructed, '?&' );
$_reconstructed = str_replace( '&', '&amp;', $_reconstructed );
//-----------------------------------------
// Add on the parameter separator
//-----------------------------------------
if( $this->settings['url_type'] == 'query_string' )
{
if( substr_count( $_reconstructed, '?' ) > 1 )
{
$_reconstructed .= '&amp;';
}
else
{
$_reconstructed .= '?';
}
}
else
{
if( strpos( $_reconstructed, '?' ) !== false )
{
$_reconstructed .= '&amp;';
}
else
{
$_reconstructed .= '?';
}
}
//-----------------------------------------
// If no pages, no need to have links
//-----------------------------------------
if( $_ttlPages < 2 )
{
return $txt;
}
//-----------------------------------------
// Do replacements
//-----------------------------------------
if( !$_curPage )
{
$txt = substr( $txt, 0, strpos( $txt, $tag ) );
}
else
{
$bits = explode( $tag, $txt );
$txt = $bits[ $_curPage - 1 ];
}
//-----------------------------------------
// Clean up leading <br /> tags
//-----------------------------------------
$txt = trim($txt);
if( substr( $txt, 0, 15 ) == '~~~~~_____~~~~~' )
{
$txt = substr( $txt, 15 );
}
//-----------------------------------------
// And start generating output
//-----------------------------------------
$txt .= $this->registry->output->getTemplate('ccs_global')->articlePages( $_ttlPages, $_curPage, $_reconstructed );
return $txt;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
+287 -287
View File
@@ -1,288 +1,288 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Simple caching class
* Last Updated: $Date: 2011-06-22 11:54:21 -0400 (Wed, 22 Jun 2011) $
* </pre>
*
* Original Author: Matt Mecham
* @author $Author: mmecham $
* @copyright (c) 2001 - 2011 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @version $Rev: 9077 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly.";
exit();
}
class classes_cache_simple
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
public $registry;
public $DB;
public $settings;
public $request;
public $lang;
public $member;
public $memberData = array( 'member_id' => 0 );
/**#@-*/
protected $app = '';
protected $me = array();
protected $meCache = array();
protected $cacheForMins = array();
/**
* Constructer
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set the default */
$this->setApp( IPS_APP_COMPONENT );
/* Set ME */
$this->setMe( $this->memberData );
/* Set default cache for mins */
$this->setCacheForMins( 5 );
}
/**
* @return the $app
*/
public function getApp()
{
return $this->app;
}
/**
* @param field_type $app
*/
public function setApp( $app )
{
$this->app = $app;
}
/**
* @return the $me
*/
public function getMe()
{
return $this->me;
}
/**
* @param array $me
*/
public function setMe( array $me )
{
$this->me = $me;
}
/**
* @return the $meCache
*/
public function getMeCache( $id )
{
return ( ! empty( $this->meCache[ $id ] ) ) ? $this->meCache[ $id ] : null;
}
/**
* @param string $meCache
*/
public function setMeCache( $meCache )
{
$me = $this->getMe();
$this->meCache[ $me['member_id'] ] = $meCache;
}
/**
* @return the $cacheForMins
*/
public function getCacheForMins()
{
return $this->cacheForMins;
}
/**
* @param field_type $cacheForMins
*/
public function setCacheForMins( $cacheForMins )
{
$this->cacheForMins = intval( $cacheForMins );
}
/**
* Return a cached item
* @param string $key
*/
public function get( $key )
{
$data = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'cache_simple',
'where' => 'cache_id=\'' . $this->DB->addSlashes( $this->_makeId( $key ) ) . '\' AND cache_perm_key=\'' . $this->DB->addSlashes( $this->_makePermKey() ) . '\'' ) );
if ( ! empty( $data['cache_id'] ) )
{
if ( ! $this->_isStale( $data ) )
{
/* Do we need to unserialize this? */
$data['cache_data'] = ( IPSLib::isSerialized( $data['cache_data'] ) ) ? unserialize( $data['cache_data'] ) : $data['cache_data'];
return array( 'data' => $data['cache_data'],
'time' => $data['cache_time'] );
}
}
return null;
}
/**
* Set a cached item
* @param string $key
* @param mixed $data If array, it will be serialized
*/
public function set( $key, $data )
{
$this->DB->replace( 'cache_simple', array( 'cache_id' => $this->_makeId( $key ),
'cache_perm_key' => $this->_makePermKey(),
'cache_time' => IPS_UNIX_TIME_NOW,
'cache_data' => is_array( $data ) ? serialize( $data ) : $data ), array( 'cache_id' ) );
return true;
}
/**
* Tests to see if a cached item is stale
* @param array $data
* @return boolean
*/
private function _isStale( array $data )
{
if ( empty( $data['cache_time'] ) )
{
return true;
}
else if ( ( IPS_UNIX_TIME_NOW - $data['cache_time'] ) > ( $this->getCacheForMins() * 60 ) )
{
return true;
}
return false;
}
/**
* Make an ID key for the DeeBee
* @param string $key
*/
private function _makeId( $key )
{
return md5( $this->getApp() . '-' . $key );
}
/**
* Make a perm key for the DeeBee
* @param string $key
*/
private function _makePermKey()
{
$me = $this->getMe();
$cached = $this->getMeCache( $me['member_id'] );
$key = ( $cached !== null ) ? $cached : $this->_makePermOrdered( $me );
if ( $cached === null && $key )
{
$this->setMeCache( $key );
}
return md5( $key );
}
/**
* Fetch all relevant Perm IDs and make them ordered
* @param array $member
*/
private function _makePermOrdered( $member )
{
$perms = array();
if ( ! empty( $member['org_perm_id'] ) )
{
$perms = explode( ',', IPSText::cleanPermString( $member['org_perm_id'] ) );
}
if ( ! count( $perms ) )
{
$groups = array( $member['member_group_id'] );
if ( ! empty( $member['mgroup_others'] ) )
{
$others = explode( ',', IPSText::cleanPermString( $member['mgroup_others'] ) );
if ( is_array( $others ) )
{
$groups = array_merge( $groups, $others );
}
}
foreach( $groups as $gid )
{
$_perms = IPSText::cleanPermString( $this->caches['group_cache'][ $gid ]['g_perm_id'] );
if ( ! empty( $_perms ) )
{
$__perms = explode( ',', $_perms );
if ( is_array( $__perms ) )
{
$perms = array_merge( $perms, $__perms );
}
}
}
}
if ( is_array( $perms ) AND count( $perms ) )
{
sort( $perms, SORT_NUMERIC );
$perms = array_unique( $perms );
return implode( ',', $perms );
}
else
{
return '';
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Simple caching class
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* Original Author: Matt Mecham
* @author $Author: bfarber $
* @copyright (c) 2001 - 2011 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 10914 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly.";
exit();
}
class classes_cache_simple
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
public $registry;
public $DB;
public $settings;
public $request;
public $lang;
public $member;
public $memberData = array( 'member_id' => 0 );
/**#@-*/
protected $app = '';
protected $me = array();
protected $meCache = array();
protected $cacheForMins = array();
/**
* Constructer
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set the default */
$this->setApp( IPS_APP_COMPONENT );
/* Set ME */
$this->setMe( $this->memberData );
/* Set default cache for mins */
$this->setCacheForMins( 5 );
}
/**
* @return the $app
*/
public function getApp()
{
return $this->app;
}
/**
* @param field_type $app
*/
public function setApp( $app )
{
$this->app = $app;
}
/**
* @return the $me
*/
public function getMe()
{
return $this->me;
}
/**
* @param array $me
*/
public function setMe( array $me )
{
$this->me = $me;
}
/**
* @return the $meCache
*/
public function getMeCache( $id )
{
return ( ! empty( $this->meCache[ $id ] ) ) ? $this->meCache[ $id ] : null;
}
/**
* @param string $meCache
*/
public function setMeCache( $meCache )
{
$me = $this->getMe();
$this->meCache[ $me['member_id'] ] = $meCache;
}
/**
* @return the $cacheForMins
*/
public function getCacheForMins()
{
return $this->cacheForMins;
}
/**
* @param field_type $cacheForMins
*/
public function setCacheForMins( $cacheForMins )
{
$this->cacheForMins = intval( $cacheForMins );
}
/**
* Return a cached item
* @param string $key
*/
public function get( $key )
{
$data = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'cache_simple',
'where' => 'cache_id=\'' . $this->DB->addSlashes( $this->_makeId( $key ) ) . '\' AND cache_perm_key=\'' . $this->DB->addSlashes( $this->_makePermKey() ) . '\'' ) );
if ( ! empty( $data['cache_id'] ) )
{
if ( ! $this->_isStale( $data ) )
{
/* Do we need to unserialize this? */
$data['cache_data'] = ( IPSLib::isSerialized( $data['cache_data'] ) ) ? unserialize( $data['cache_data'] ) : $data['cache_data'];
return array( 'data' => $data['cache_data'],
'time' => $data['cache_time'] );
}
}
return null;
}
/**
* Set a cached item
* @param string $key
* @param mixed $data If array, it will be serialized
*/
public function set( $key, $data )
{
$this->DB->replace( 'cache_simple', array( 'cache_id' => $this->_makeId( $key ),
'cache_perm_key' => $this->_makePermKey(),
'cache_time' => IPS_UNIX_TIME_NOW,
'cache_data' => is_array( $data ) ? serialize( $data ) : $data ), array( 'cache_id' ) );
return true;
}
/**
* Tests to see if a cached item is stale
* @param array $data
* @return boolean
*/
private function _isStale( array $data )
{
if ( empty( $data['cache_time'] ) )
{
return true;
}
else if ( ( IPS_UNIX_TIME_NOW - $data['cache_time'] ) > ( $this->getCacheForMins() * 60 ) )
{
return true;
}
return false;
}
/**
* Make an ID key for the DeeBee
* @param string $key
*/
private function _makeId( $key )
{
return md5( $this->getApp() . '-' . $key );
}
/**
* Make a perm key for the DeeBee
* @param string $key
*/
private function _makePermKey()
{
$me = $this->getMe();
$cached = $this->getMeCache( $me['member_id'] );
$key = ( $cached !== null ) ? $cached : $this->_makePermOrdered( $me );
if ( $cached === null && $key )
{
$this->setMeCache( $key );
}
return md5( $key );
}
/**
* Fetch all relevant Perm IDs and make them ordered
* @param array $member
*/
private function _makePermOrdered( $member )
{
$perms = array();
if ( ! empty( $member['org_perm_id'] ) )
{
$perms = explode( ',', IPSText::cleanPermString( $member['org_perm_id'] ) );
}
if ( ! count( $perms ) )
{
$groups = array( $member['member_group_id'] );
if ( ! empty( $member['mgroup_others'] ) )
{
$others = explode( ',', IPSText::cleanPermString( $member['mgroup_others'] ) );
if ( is_array( $others ) )
{
$groups = array_merge( $groups, $others );
}
}
foreach( $groups as $gid )
{
$_perms = IPSText::cleanPermString( $this->caches['group_cache'][ $gid ]['g_perm_id'] );
if ( ! empty( $_perms ) )
{
$__perms = explode( ',', $_perms );
if ( is_array( $__perms ) )
{
$perms = array_merge( $perms, $__perms );
}
}
}
}
if ( is_array( $perms ) AND count( $perms ) )
{
sort( $perms, SORT_NUMERIC );
$perms = array_unique( $perms );
return implode( ',', $perms );
}
else
{
return '';
}
}
}
@@ -1,331 +1,340 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Control Panel Functions
* Last Updated: $Date: 2011-09-13 21:55:41 -0400 (Tue, 13 Sep 2011) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Tue. 17th August 2004
* @version $Rev: 9487 $
*
*/
class adminFunctions
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**#@+
* Security keys
*
* @access public
* @var string
*/
public $generated_acp_hash;
public $_admin_auth_key;
/**#@-*/
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->generated_acp_hash = $this->generateSecureHash();
$this->_admin_auth_key = $this->getSecurityKey();
$this->registry->output->global_template = $this->registry->output->loadRootTemplate('cp_skin_global');
//------------------------------------------
// Message in a bottle?
//------------------------------------------
if( !empty($this->request['messageinabottleacp']) )
{
$this->request['messageinabottleacp'] = IPSText::getTextClass('bbcode')->xssHtmlClean( IPSText::UNhtmlspecialchars( urldecode( $this->request['messageinabottleacp'] ) ) );
$this->registry->output->global_message = $this->request['messageinabottleacp'];
$this->registry->output->persistent_message = intval($this->request['messagepersistent']);
}
}
/**
* Fetch mod_rewrite rules
*
* @access public
* @return string
*/
public function fetchModRewrite()
{
$rules = '';
$_parse = parse_url( $this->settings['base_url'] );
$_root = preg_replace( "#/$#", "", $_parse['path'] );
$_root = str_replace( '/' . CP_DIRECTORY, '', $_root );
$_root = str_replace( 'index.php', '', $_root );
$rules = "&lt;IfModule mod_rewrite.c&gt;\n";
$rules .= "Options -MultiViews\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $_root\n";
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
"RewriteCond %{REQUEST_FILENAME} !-d\n" .
"RewriteRule . {$_root}index.php [L]\n";
$rules .= "&lt;/IfModule&gt;\n";
return $rules;
}
/**
* Get the staff member's "cookie"
*
* @access public
* @param string Key
* @param integer Member ID [defaults to current member]
* @return mixed Stored cookie
*/
public function staffGetCookie( $key, $id=0 )
{
//-----------------------------------------
// INIT, Yes, it is.
//-----------------------------------------
$id = ( $id ) ? $id : $this->memberData['member_id'];
$_test = $this->DB->buildAndFetch( array(
'select' => 'sys_login_id, sys_cookie',
'from' => 'core_sys_login',
'where' => 'sys_login_id=' . intval( $id )
) );
$cookie = ( $_test['sys_cookie'] ) ? unserialize( $_test['sys_cookie'] ) : array();
return ( isset( $cookie[ $key ] ) ) ? $cookie[ $key ] : null;
}
/**
* Update the member's "cookie"
*
* @access public
* @param string Key
* @param mixed Data
* @param integer Member id [defaults to current member]
* @return boolean
*/
public function staffSaveCookie( $key, $data, $id=0 )
{
//-----------------------------------------
// INIT, Yes, it is.
//-----------------------------------------
$id = ( $id ) ? $id : $this->memberData['member_id'];
$_test = $this->DB->buildAndFetch( array( 'select' => 'sys_login_id, sys_cookie',
'from' => 'core_sys_login',
'where' => 'sys_login_id=' . intval( $id )
) );
$cookie = ( $_test['sys_cookie'] ) ? unserialize( $_test['sys_cookie'] ) : array();
$cookie[ $key ] = $data;
if ( $_test['sys_login_id'] )
{
$this->DB->update( 'core_sys_login', array( 'sys_cookie' => serialize( $cookie ) ), 'sys_login_id=' . intval( $id ) );
}
else
{
$this->DB->insert( 'core_sys_login', array( 'sys_cookie' => serialize( $cookie ), 'sys_login_id' => intval( $id ) ) );
}
return TRUE;
}
/**
* Generate a md5 hash, used for authenticating forms
*
* @access public
* @return string MD5 secure hash
* @see getSecurityKey()
*/
public function generateSecureHash()
{
/* Generate Secure Hash */
if ( IPB_ACP_IP_MATCH )
{
$ip_octets = explode( ".", $this->member->ip_address );
$key = md5( ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . "(&)" . $ip_octets[0] . '(&)' . $ip_octets[1] . '(&)' . ( isset($this->memberData['member_login_key']) ? $this->memberData['member_login_key'] : 0 ) );
}
else
{
$key = md5( ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '(&)' . ( isset($this->memberData['member_login_key']) ? $this->memberData['member_login_key'] : 0 ) );
}
return $key;
}
/**
* Generate a md5 hash, used for authenticating forms
*
* @access public
* @return string MD5 secure hash
* @see checkSecurityKey()
* @see getSecurityKey()
*/
public function getSecurityKey()
{
if ( IPB_ACP_IP_MATCH )
{
return md5( ( isset($this->memberData['email']) ? $this->memberData['email'] : 0 ) . '^' . ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '^' . $this->member->ip_address . md5( $this->settings['sql_pass'] ) );
}
else
{
return md5( ( isset($this->memberData['email']) ? $this->memberData['email'] : 0 ) . '^' . ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '^' . md5( $this->settings['sql_pass'] ) );
}
}
/**
* Checks the security key
*
* @access public
* @param string md5 auth key [defaults to $_POST['_admin_auth_key']]
* @param boolean return and not die?
* @return mixed boolean false or outputs error on failure, else true
* @see getSecurityKey()
*/
public function checkSecurityKey( $auth_key='', $return_and_not_die=false )
{
$auth_key = ( $auth_key ) ? $auth_key : trim( $_POST['_admin_auth_key'] );
if ( $auth_key != $this->getSecurityKey() )
{
if ( $return_and_not_die )
{
return FALSE;
}
else
{
$this->registry->output->showError( $this->lang->words['func_security_mismatch'], 2100, null, null, 403 );
exit();
}
}
return true;
}
/**
* Save an entry to the admin logs
*
* @access public
* @param string Action
* @return boolean
*/
public function saveAdminLog( $action="" )
{
$this->DB->insert( 'admin_logs', array( 'appcomponent' => $this->request['app'],
'module' => $this->request['module'],
'section' => $this->request['section'],
'do' => $this->request['do'],
'member_id' => $this->memberData['member_id'],
'ctime' => time(),
'note' => $action,
'ip_address' => $this->member->ip_address,
) );
return true;
}
/**
* Import an XML file either from a fixed server location
* or via the upload fields. Upload fields are checked first
*
* @access public
* @param string File location
* @return string XML contents
* @note This function is not restricted to XML. It will return the contents of the uploaded file regardless of file type.
* @todo [Future] We should rename this function to something more generic. It is not restricted to 'xml' so the name is misleading.
*/
public function importXml( $location='' )
{
//-----------------------------------------
// Upload
//-----------------------------------------
$FILE_NAME = $_FILES['FILE_UPLOAD']['name'];
$FILE_TYPE = $_FILES['FILE_UPLOAD']['type'];
$UPLOAD_DIR = ( $this->settings['upload_dir'] AND is_dir( $this->settings['upload_dir'] ) ) ? $this->settings['upload_dir'] : DOC_IPS_ROOT_PATH.'uploads';
//-----------------------------------------
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
//-----------------------------------------
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
$content = "";
if ( $FILE_NAME AND ( $FILE_NAME != 'none' ) )
{
if ( move_uploaded_file( $_FILES[ 'FILE_UPLOAD' ]['tmp_name'], $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
$location = $UPLOAD_DIR . "/" . $FILE_NAME;
}
}
/* Now load it... $location could have been set by the upload check...*/
if ( is_file( $location ) )
{
if ( substr( $location, -3 ) == '.gz' )
{
if ( $FH = @gzopen( $location, 'rb' ) )
{
while ( ! @gzeof( $FH ) )
{
$content .= @gzread( $FH, 1024 );
}
@gzclose( $FH );
}
}
else //if ( substr( $location, -4 ) == '.xml' )
{
$content = file_get_contents( $location );
}
}
/* Unlink the tmp file if it exists */
if ( is_file( $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
@unlink( $UPLOAD_DIR . "/" . $FILE_NAME );
}
return $content;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Control Panel Functions
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Tue. 17th August 2004
* @version $Rev: 10914 $
*
*/
class adminFunctions
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**#@+
* Security keys
*
* @access public
* @var string
*/
public $generated_acp_hash;
public $_admin_auth_key;
/**#@-*/
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->generated_acp_hash = $this->generateSecureHash();
$this->_admin_auth_key = $this->getSecurityKey();
$this->registry->output->global_template = $this->registry->output->loadRootTemplate('cp_skin_global');
//------------------------------------------
// Message in a bottle?
//------------------------------------------
if( !empty($this->request['messageinabottleacp']) )
{
$this->request['messageinabottleacp'] = IPSText::getTextClass('bbcode')->xssHtmlClean( IPSText::UNhtmlspecialchars( urldecode( $this->request['messageinabottleacp'] ) ) );
$this->registry->output->global_message = $this->request['messageinabottleacp'];
$this->registry->output->persistent_message = intval($this->request['messagepersistent']);
}
}
/**
* Fetch mod_rewrite rules
*
* @access public
* @return string
*/
public function fetchModRewrite()
{
$rules = '';
$_parse = parse_url( $this->settings['base_url'] );
$_root = preg_replace( "#/$#", "", $_parse['path'] );
$_root = str_replace( '/' . CP_DIRECTORY, '', $_root );
$_root = str_replace( 'index.php', '', $_root );
$rules = "&lt;IfModule mod_rewrite.c&gt;\n";
$rules .= "Options -MultiViews\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $_root\n";
$rules .= "RewriteCond %{REQUEST_FILENAME} .*\.(jpeg|jpg|gif|png)$\n";
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n";
$rules .= "RewriteRule . {$_root}public/404.php [L]\n\n";
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
"RewriteCond %{REQUEST_FILENAME} !-d\n" .
"RewriteRule . {$_root}index.php [L]\n";
$rules .= "&lt;/IfModule&gt;\n";
return $rules;
}
/**
* Get the staff member's "cookie"
*
* @access public
* @param string Key
* @param integer Member ID [defaults to current member]
* @return mixed Stored cookie
*/
public function staffGetCookie( $key, $id=0 )
{
//-----------------------------------------
// INIT, Yes, it is.
//-----------------------------------------
$id = ( $id ) ? $id : $this->memberData['member_id'];
$_test = $this->DB->buildAndFetch( array(
'select' => 'sys_login_id, sys_cookie',
'from' => 'core_sys_login',
'where' => 'sys_login_id=' . intval( $id )
) );
$cookie = ( $_test['sys_cookie'] ) ? unserialize( $_test['sys_cookie'] ) : array();
return ( isset( $cookie[ $key ] ) ) ? $cookie[ $key ] : null;
}
/**
* Update the member's "cookie"
*
* @access public
* @param string Key
* @param mixed Data
* @param integer Member id [defaults to current member]
* @return boolean
*/
public function staffSaveCookie( $key, $data, $id=0 )
{
//-----------------------------------------
// INIT, Yes, it is.
//-----------------------------------------
$id = ( $id ) ? $id : $this->memberData['member_id'];
$_test = $this->DB->buildAndFetch( array( 'select' => 'sys_login_id, sys_cookie',
'from' => 'core_sys_login',
'where' => 'sys_login_id=' . intval( $id )
) );
$cookie = ( $_test['sys_cookie'] ) ? unserialize( $_test['sys_cookie'] ) : array();
$cookie[ $key ] = $data;
if ( $_test['sys_login_id'] )
{
$this->DB->update( 'core_sys_login', array( 'sys_cookie' => serialize( $cookie ) ), 'sys_login_id=' . intval( $id ) );
}
else
{
$this->DB->insert( 'core_sys_login', array( 'sys_cookie' => serialize( $cookie ), 'sys_login_id' => intval( $id ) ) );
}
return TRUE;
}
/**
* Generate a md5 hash, used for authenticating forms
*
* @access public
* @return string MD5 secure hash
* @see getSecurityKey()
*/
public function generateSecureHash()
{
/* Generate Secure Hash */
if ( IPB_ACP_IP_MATCH )
{
$ip_octets = explode( ".", $this->member->ip_address );
$key = md5( ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . "(&)" . $ip_octets[0] . '(&)' . $ip_octets[1] . '(&)' . ( isset($this->memberData['member_login_key']) ? $this->memberData['member_login_key'] : 0 ) );
}
else
{
$key = md5( ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '(&)' . ( isset($this->memberData['member_login_key']) ? $this->memberData['member_login_key'] : 0 ) );
}
return $key;
}
/**
* Generate a md5 hash, used for authenticating forms
*
* @access public
* @return string MD5 secure hash
* @see checkSecurityKey()
* @see getSecurityKey()
*/
public function getSecurityKey()
{
if ( IPB_ACP_IP_MATCH )
{
return md5( ( isset($this->memberData['email']) ? $this->memberData['email'] : 0 ) . '^' . ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '^' . $this->member->ip_address . md5( $this->settings['sql_pass'] ) );
}
else
{
return md5( ( isset($this->memberData['email']) ? $this->memberData['email'] : 0 ) . '^' . ( isset($this->memberData['joined']) ? $this->memberData['joined'] : 0 ) . '^' . md5( $this->settings['sql_pass'] ) );
}
}
/**
* Checks the security key
*
* @access public
* @param string md5 auth key [defaults to $_POST['_admin_auth_key']]
* @param boolean return and not die?
* @return mixed boolean false or outputs error on failure, else true
* @see getSecurityKey()
*/
public function checkSecurityKey( $auth_key='', $return_and_not_die=false )
{
$auth_key = ( $auth_key ) ? $auth_key : trim( $_POST['_admin_auth_key'] );
if ( $auth_key != $this->getSecurityKey() )
{
if ( $return_and_not_die )
{
return FALSE;
}
else
{
$this->registry->output->showError( $this->lang->words['func_security_mismatch'], 2100, null, null, 403 );
exit();
}
}
return true;
}
/**
* Save an entry to the admin logs
*
* @access public
* @param string Action
* @return boolean
*/
public function saveAdminLog( $action="" )
{
$this->DB->insert( 'admin_logs', array( 'appcomponent' => $this->request['app'],
'module' => $this->request['module'],
'section' => $this->request['section'],
'do' => $this->request['do'],
'member_id' => $this->memberData['member_id'],
'ctime' => time(),
'note' => $action,
'ip_address' => $this->member->ip_address,
) );
return true;
}
/**
* Import an XML file either from a fixed server location
* or via the upload fields. Upload fields are checked first
*
* @access public
* @param string File location
* @return string XML contents
* @throws Exception Throws Exception gz_not_available if the zlib extension is not installed
* @note This function is not restricted to XML. It will return the contents of the uploaded file regardless of file type.
* @todo [Future] We should rename this function to something more generic. It is not restricted to 'xml' so the name is misleading.
*/
public function importXml( $location='' )
{
//-----------------------------------------
// Upload
//-----------------------------------------
$FILE_NAME = $_FILES['FILE_UPLOAD']['name'];
$FILE_TYPE = $_FILES['FILE_UPLOAD']['type'];
$UPLOAD_DIR = ( $this->settings['upload_dir'] AND is_dir( $this->settings['upload_dir'] ) ) ? $this->settings['upload_dir'] : DOC_IPS_ROOT_PATH.'uploads';
//-----------------------------------------
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
//-----------------------------------------
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
$content = "";
if ( $FILE_NAME AND ( $FILE_NAME != 'none' ) )
{
if ( move_uploaded_file( $_FILES[ 'FILE_UPLOAD' ]['tmp_name'], $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
$location = $UPLOAD_DIR . "/" . $FILE_NAME;
}
}
/* Now load it... $location could have been set by the upload check...*/
if ( is_file( $location ) )
{
if ( substr( $location, -3 ) == '.gz' )
{
if ( !function_exists( 'gzopen' ) )
{
throw new Exception( 'gz_not_available' );
}
if ( $FH = @gzopen( $location, 'rb' ) )
{
while ( ! @gzeof( $FH ) )
{
$content .= @gzread( $FH, 1024 );
}
@gzclose( $FH );
}
}
else //if ( substr( $location, -4 ) == '.xml' )
{
$content = file_get_contents( $location );
}
}
/* Unlink the tmp file if it exists */
if ( is_file( $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
@unlink( $UPLOAD_DIR . "/" . $FILE_NAME );
}
return $content;
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,267 +1,267 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Editor Library: Core Class
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*
* EXAMPLE USAGE
* <code>
* $han_editor = new han_editor();
*
* $han_editor->init();
*
* # To generate the HTML for the editor:
* $editor_html = $han_editor->showEditor( $raw_post, 'Post' );
*
* # $raw_post is either raw HTML for the rich text editor or raw BBCode tagged text when
* # using the standard editor. (See the document on the BBCode parser for more information)
* # 'Post' is the name of the form field you wish use. In this case it'll return $_POST['Post'].
*
* #To process the editor's text into tagged BBCode text:
* $post = $han_editor->processRawPost( 'Post' );
*
* #'Post' is the name of the form field you used when displaying the editor. As in $_POST['Post']
*
* # To use the HTML generated by editor class for displaying the actual editor (in our example; $editor_html)
* # you'll need to use it like this:
*
* <form id='postingform' onsubmit='return ValidateForm()' action="$url" method="post" name="REPLIER">
* {$editor_html}
* <br /><input type="submit" value="Post" /></div>
* </form>
*
* The form tag MUST have: id='postingform' onsubmit='return ValidateForm()' otherwise the editor will fail.
* </code>
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class class_editor
{
/**
* Allow unicode setting
*
* @access public
* @var boolean
*/
public $allow_unicode;
/**
* Get magic quotes
*
* @access public
* @var boolean
*/
public $get_magic_quotes;
/**
* Reverse font sizes
*
* @access public
* @var array
*/
public $rev_font_sizes = array();
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Main font sizes
*
* @access protected
* @var array
*/
protected $font_sizes = array( 1 => 8,
2 => 10,
3 => 12,
4 => 14,
5 => 18,
6 => 24,
7 => 36 );
/**
* Constructor
*
* @access public
* @param object Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Main init: Prep font sizes
*
* @access public
* @return @e void
*/
public function editorInit( )
{
foreach( $this->font_sizes as $bbcode => $real )
{
$this->rev_font_sizes[ $real ] = $bbcode;
}
}
/**
* Get BBCode font size from real PX size
*
* @access public
* @param integer PX Size
* @return integer BBCode size
*/
public function convertRealsizeToBbsize( $real )
{
$real = intval( $real );
if ( $this->rev_font_sizes[ $real ] )
{
return $this->rev_font_sizes[ $real ];
}
else
{
return 2;
}
}
/**
* Clean up and make the post safe for the DB
*
* @access protected
* @param string Raw text
* @return string Converted text
*/
protected function _cleanPost( $t )
{
if ( $t == "" )
{
return "";
}
//-----------------------------------------
// Make it safe
//-----------------------------------------
$t = str_replace( "&" , "&amp;" , $t );
$t = str_replace( "<!--" , "&#60;&#33;--" , $t );
$t = str_replace( "-->" , "--&#62;" , $t );
$t = str_ireplace( "<script" , "&#60;script" , $t );
$t = str_replace( ">" , "&gt;" , $t );
$t = str_replace( "<" , "&lt;" , $t );
$t = str_replace( '"' , "&quot;" , $t );
$t = str_replace( "\n" , "<br />" , $t );
$t = str_replace( '$' , "&#036;" , $t );
$t = str_replace( "\r" , "" , $t );
$t = str_replace( "!" , "&#33;" , $t );
$t = str_replace( "'" , "&#39;" , $t );
//-----------------------------------------
// Ensure unicode chars are OK
//-----------------------------------------
if ( $this->allow_unicode )
{
$t = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $t );
}
//-----------------------------------------
// Strip slashes if not already done so.
//-----------------------------------------
/*if ( $this->get_magic_quotes )
{
$t = stripslashes($t);
}*/
//-----------------------------------------
// Swap user inputted backslashes
//-----------------------------------------
$t = preg_replace( "/\\\(?!&amp;#|\?#)/", "&#092;", $t );
return $t;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Editor Library: Core Class
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*
* EXAMPLE USAGE
* <code>
* $han_editor = new han_editor();
*
* $han_editor->init();
*
* # To generate the HTML for the editor:
* $editor_html = $han_editor->showEditor( $raw_post, 'Post' );
*
* # $raw_post is either raw HTML for the rich text editor or raw BBCode tagged text when
* # using the standard editor. (See the document on the BBCode parser for more information)
* # 'Post' is the name of the form field you wish use. In this case it'll return $_POST['Post'].
*
* #To process the editor's text into tagged BBCode text:
* $post = $han_editor->processRawPost( 'Post' );
*
* #'Post' is the name of the form field you used when displaying the editor. As in $_POST['Post']
*
* # To use the HTML generated by editor class for displaying the actual editor (in our example; $editor_html)
* # you'll need to use it like this:
*
* <form id='postingform' onsubmit='return ValidateForm()' action="$url" method="post" name="REPLIER">
* {$editor_html}
* <br /><input type="submit" value="Post" /></div>
* </form>
*
* The form tag MUST have: id='postingform' onsubmit='return ValidateForm()' otherwise the editor will fail.
* </code>
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class class_editor
{
/**
* Allow unicode setting
*
* @access public
* @var boolean
*/
public $allow_unicode;
/**
* Get magic quotes
*
* @access public
* @var boolean
*/
public $get_magic_quotes;
/**
* Reverse font sizes
*
* @access public
* @var array
*/
public $rev_font_sizes = array();
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Main font sizes
*
* @access protected
* @var array
*/
protected $font_sizes = array( 1 => 8,
2 => 10,
3 => 12,
4 => 14,
5 => 18,
6 => 24,
7 => 36 );
/**
* Constructor
*
* @access public
* @param object Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Main init: Prep font sizes
*
* @access public
* @return @e void
*/
public function editorInit( )
{
foreach( $this->font_sizes as $bbcode => $real )
{
$this->rev_font_sizes[ $real ] = $bbcode;
}
}
/**
* Get BBCode font size from real PX size
*
* @access public
* @param integer PX Size
* @return integer BBCode size
*/
public function convertRealsizeToBbsize( $real )
{
$real = intval( $real );
if ( $this->rev_font_sizes[ $real ] )
{
return $this->rev_font_sizes[ $real ];
}
else
{
return 2;
}
}
/**
* Clean up and make the post safe for the DB
*
* @access protected
* @param string Raw text
* @return string Converted text
*/
protected function _cleanPost( $t )
{
if ( $t == "" )
{
return "";
}
//-----------------------------------------
// Make it safe
//-----------------------------------------
$t = str_replace( "&" , "&amp;" , $t );
$t = str_replace( "<!--" , "&#60;&#33;--" , $t );
$t = str_replace( "-->" , "--&#62;" , $t );
$t = str_ireplace( "<script" , "&#60;script" , $t );
$t = str_replace( ">" , "&gt;" , $t );
$t = str_replace( "<" , "&lt;" , $t );
$t = str_replace( '"' , "&quot;" , $t );
$t = str_replace( "\n" , "<br />" , $t );
$t = str_replace( '$' , "&#036;" , $t );
$t = str_replace( "\r" , "" , $t );
$t = str_replace( "!" , "&#33;" , $t );
$t = str_replace( "'" , "&#39;" , $t );
//-----------------------------------------
// Ensure unicode chars are OK
//-----------------------------------------
if ( $this->allow_unicode )
{
$t = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $t );
}
//-----------------------------------------
// Strip slashes if not already done so.
//-----------------------------------------
/*if ( $this->get_magic_quotes )
{
$t = stripslashes($t);
}*/
//-----------------------------------------
// Swap user inputted backslashes
//-----------------------------------------
$t = preg_replace( "/\\\(?!&amp;#|\?#)/", "&#092;", $t );
return $t;
}
}
@@ -3,18 +3,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Editor Library: RTE (WYSIWYG) Class
* Last Updated: $Date: 2011-04-19 12:42:57 -0400 (Tue, 19 Apr 2011) $
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 8391 $
* @version $Revision: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -144,7 +144,7 @@ class class_editor_module extends class_editor
$t = str_ireplace( "<br />\n", "<br />", $t );
$t = str_ireplace( "<br />\r", "<br />", $t );
//$t = preg_replace( "/((?:\r)?\n?(?:[\r|\n|\t| ])+)/", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/u", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/", " ", $t );
}
else
@@ -285,7 +285,7 @@ class class_editor_module extends class_editor
$t = str_ireplace( "<br />\n", "<br />", $t );
$t = str_ireplace( "<br />\r", "<br />", $t );
//$t = preg_replace( "/((?:\r)?\n?(?:[\r|\n|\t| ])+)/", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/u", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/", " ", $t );
}
else
@@ -962,7 +962,7 @@ class class_editor_module extends class_editor
while ( $tag_begin_loc !== FALSE )
{
$lowtext = mb_strtolower($text);
$lowtext = strtolower($text);
$tag_begin_loc = @strpos( $lowtext, $open_tag, $start_search_pos );
$lentext = strlen($text);
$quoted = '';
@@ -3,18 +3,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Editor Library: Standard Class
* Last Updated: $Date: 2010-12-17 08:01:38 -0500 (Fri, 17 Dec 2010) $
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 7445 $
* @version $Revision: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
+507 -135
View File
@@ -3,18 +3,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Editor Library: RTE (WYSIWYG) Class
* Last Updated: $Date: 2011-10-11 07:49:07 -0400 (Tue, 11 Oct 2011) $
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: mmecham $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 9593 $
* @version $Revision: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -31,8 +31,8 @@ if ( ! defined( 'IN_IPB' ) )
* non char set characters converted into their numeric equivalent &#xxx; make
* every effort to not auto-parse typed in entities. That is, if someone types in &#39; it
* should NOT convert that to ' when they hit submit.
* Test input: < > ' " & ¦ $ \ ! &amp; &#39; &quot; &lt; &gt; &para;
* Should be processed as: &lt; &gt; &#39; &quot; &amp; ¦ $ &#92; ! &amp;amp; &amp;#39; &amp;quot; &amp;lt; &amp;gt; &amp;para;
* Test input: < > ' " & ¦ $ \ ! &amp; &#39; &quot; &lt; &gt; &para;
* Should be processed as: &lt; &gt; &#39; &quot; &amp; ¦ $ &#92; ! &amp;amp; &amp;#39; &amp;quot; &amp;lt; &amp;gt; &amp;para;
* This is *the* golden rule. Use this to test any fixes. It must work in the following modes:
* RTE > STD Switch
* STD > RTE Switch
@@ -65,6 +65,7 @@ class classes_editor_composite
* Use P for line breaks (std CKEditor mode)
*/
const IPS_P_MODE = true;
/**
* Parsing array
*
@@ -101,8 +102,9 @@ class classes_editor_composite
* Internal setting objects
*
* @var boolean
*/
protected $allowHtml = false;
*/
protected $isHtml = null;
protected $allowHtml = null;
protected $allowBbcode = true;
protected $content = null;
protected $rteEnabled = false;
@@ -176,6 +178,27 @@ class classes_editor_composite
}
}
/**
* @return the $isHtml
*/
public function getIsHtml()
{
return $this->isHtml;
}
/**
* @return the $isHtml
*/
public function setIsHtml( $isHtml )
{
$this->isHtml = $isHtml ? true : false;
if ( $isHtml )
{
$this->setAllowHtml( true );
}
}
/**
* @return the $allowSmilies
*/
@@ -221,6 +244,12 @@ class classes_editor_composite
*/
public function setAllowHtml( $allowHtml )
{
/* No mechanics in the mobile skin to deal with this */
if ( $this->registry->output->getAsMobileSkin() )
{
$allowHtml = false;
}
$this->allowHtml = $allowHtml ? true : false;
}
@@ -259,6 +288,12 @@ class classes_editor_composite
return $content;
}
/* Forcing HTML, forces STD */
if ( $this->getIsHtml() && ! IN_ACP )
{
$rteMethod = 'std';
}
/* Fix method */
switch ( $rteMethod )
{
@@ -273,45 +308,52 @@ class classes_editor_composite
break;
}
/* Setup our parser class partially here */
IPSText::getTextClass('bbcode')->parse_smilies = $this->getAllowSmilies();
IPSText::getTextClass('bbcode')->parse_bbcode = $this->getAllowBbcode();
IPSText::getTextClass('bbcode')->parsing_section = $section;
/* RTE needs a code tidy whereas STD needs BBCode */
if ( $isRte )
{
/* More parser setup #1 */
IPSText::getTextClass('bbcode')->parse_html = 0;
if ( $this->getAllowHtml() )
{
if ( ! IPSText::getTextClass('bbcode')->parse_nl2br )
{
$content = str_replace( '<br />', "", $content );
$content = str_replace( '<br>' , "", $content );
}
$content = IPSText::UNhtmlspecialchars( $content );
}
else
{
$content = $this->_rtePreShow( IPSText::getTextClass('bbcode')->convertForRTE( $content ), true );
}
$content = $this->_rtePreShow( IPSText::getTextClass('bbcode')->convertForRTE( $content ), true );
}
else
{
IPSText::getTextClass('bbcode')->parse_html = $this->getAllowHtml();
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
IPSText::getTextClass('bbcode')->parse_smilies = $this->getAllowSmilies();
IPSText::getTextClass('bbcode')->parse_bbcode = $this->getAllowBbcode();
IPSText::getTextClass('bbcode')->parsing_section = $section;
if ( $this->getAllowHtml() )
{
if ( ! IPSText::getTextClass('bbcode')->parse_nl2br )
{
$content = str_replace( '<br />', "", $content );
$content = str_replace( '<br>' , "", $content );
}
}
/* More parser setup #2 */
IPSText::getTextClass('bbcode')->parse_html = $this->getAllowHtml();
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
if ( IPS_QUICK_EDIT_TO_FULL )
{
$content = str_replace( '&', '&amp;', $content );
$content = preg_replace( '#<br([^>])?>#', '&lt;br\1&gt;', $content );
}
if ( IN_ACP && $this->getIsHtml() )
{
/* Test to see if we need to convert */
if ( strstr( $content, '[/' ) )
{
$content = str_replace( '<br />', "<br />\n", IPSText::getTextClass('bbcode')->convertForRTE( $content ) );
}
$content = $this->_stdPreShow( $content );
}
else
{
$content = $this->_stdPreShow( IPSText::getTextClass('bbcode')->preEditParse( $content ) );
}
$content = $this->_stdPreShow( IPSText::getTextClass('bbcode')->preEditParse( $content ) );
/* This is designed only for new STD forms with content and NOT when switching modes */
if ( ! IPS_IS_AJAX )
@@ -324,6 +366,7 @@ class classes_editor_composite
}
}
$content = $this->_convertNumericEntityToNamed( $content );
$content = $this->_allowNonUtf8CharsWhenNotUsingUtf8Doc( $content );
return $content;
@@ -351,6 +394,18 @@ class classes_editor_composite
*/
protected function _canWeRte()
{
/* Sent inline */
if ( isset( $_REQUEST['isRte'] ) && $_REQUEST['isRte'] == 1 )
{
return true;
}
/* Enforce bypass for mobile skin */
if ( $this->registry->output->getAsMobileSkin() && !IN_ACP )
{
return false;
}
$return = FALSE;
if ( $this->memberData['userAgentKey'] == 'explorer' AND $this->memberData['userAgentVersion'] >= 7 )
@@ -401,6 +456,18 @@ class classes_editor_composite
*/
protected function _isInSourceMode()
{
/* Forced into HTML mode? */
if ( $this->getIsHtml() )
{
return true;
}
/* If we're using the mobile skin, then force STD */
if ( $this->registry->getClass('output')->getAsMobileSkin() )
{
return true;
}
/* Sent inline */
if ( isset( $_REQUEST['isRte'] ) )
{
@@ -425,6 +492,12 @@ class classes_editor_composite
*/
public function show( $fieldName, $options=array(), $content='' )
{
/* Have we forced RTE? */
if ( ! empty( $this->request['isRte'] ) )
{
$options['isRte'] = intval( $this->request['isRte'] );
}
$_autoSaveKeyOrig = ( ! empty( $options['autoSaveKey'] ) ) ? $options['autoSaveKey'] : '';
$options['editorName'] = ( ! empty( $options['editorName'] ) ) ? $options['editorName'] : $this->_fetchEditorName();
$options['autoSaveKey'] = ( $_autoSaveKeyOrig && $this->memberData['member_id'] ) ? $this->_generateAutoSaveKey( $_autoSaveKeyOrig ) : '';
@@ -436,25 +509,195 @@ class classes_editor_composite
$options['delayInit'] = ( ! empty( $options['delayInit'] ) ) ? 1 : 0;
$options['smilies'] = $this->fetchEmoticons( 20 );
$options['bypassCKEditor'] = $this->getRteEnabled() ? 0 : 1;
$options['isRte'] = $this->_isInSourceMode() ? 0 : 1;
$options['isRte'] = ( isset( $options['isRte'] ) ) ? $options['isRte'] : ( $this->_isInSourceMode() ? 0 : 1 );
$html = '';
/* If we're using the mobile skin, then force STD */
if ( $this->registry->getClass('output')->getAsMobileSkin() )
{
$options['isRte'] = 0;
}
if ( isset( $options['recover'] ) )
{
$content = $_POST['Post'];
}
if ( ! empty( $options['isHtml'] ) )
{
$this->setIsHtml( true );
if ( IN_ACP )
{
$options['type'] = 'ipsacp';
}
}
else if ( $this->getIsHtml() )
{
$options['isHtml'] = 1;
}
/* inline content */
if ( $content )
{
$this->setContent( str_replace( '\\\'', '\'', $content ) );
}
/* Store last editor ID in case calling scripts need it */
$this->settings['_lastEditorId'] = $options['editorName'];
if ( IN_ACP )
{
{
$html = $this->registry->getClass('output')->global_template->editor( $fieldName, $this->getContent(), $options, $this->getAutoSavedContent( $_autoSaveKeyOrig ) );
}
else
{
$html = $this->registry->getClass('output')->getTemplate('editors')->editor( $fieldName, $this->getContent(), $options, $this->getAutoSavedContent( $_autoSaveKeyOrig ) );
$warningInfo = '';
$acknowledge = FALSE;
//-----------------------------------------
// Warnings
//-----------------------------------------
if ( isset( $options['warnInfo'] ) and $this->memberData['member_id'] )
{
$message = '';
/* Have they been restricted from posting? */
if ( $this->memberData['restrict_post'] )
{
$data = IPSMember::processBanEntry( $this->memberData['restrict_post'] );
if ( $data['date_end'] )
{
if ( time() >= $data['date_end'] )
{
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'restrict_post' => 0 ) ) );
}
else
{
$message = sprintf( $this->lang->words['warnings_restrict_post_temp'], $this->lang->getDate( $data['date_end'], 'JOINED' ) );
}
}
else
{
$message = $this->lang->words['warnings_restrict_post_perm'];
}
if ( $this->memberData['unacknowledged_warnings'] )
{
$warn = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_rpa<>0", 'order' => 'wl_date DESC', 'limit' => 1 ) );
if ( $warn['wl_id'] )
{
$moredetails = "<a href='javascript:void(0);' onclick='warningPopup( this, {$warn['wl_id']} )'>{$this->lang->words['warnings_moreinfo']}</a>";
}
}
if ( $options['warnInfo'] == 'full' )
{
$this->registry->getClass('output')->showError( "{$message} {$moredetails}", 103126, null, null, 403 );
}
}
/* Nope? - Requires a new if in case time restriction got just removed */
if ( empty($message) )
{
/* Do they have any warnings they have to acknowledge? */
if ( $this->memberData['unacknowledged_warnings'] )
{
$unAcknowledgedWarns = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_acknowledged=0", 'order' => 'wl_date DESC', 'limit' => 1 ) );
if ( $unAcknowledgedWarns['wl_id'] )
{
if ( $options['warnInfo'] == 'full' )
{
$this->registry->getClass('output')->silentRedirect( $this->registry->getClass('output')->buildUrl( "app=members&amp;module=profile&amp;section=warnings&amp;do=acknowledge&amp;id={$unAcknowledgedWarns['wl_id']}" ) );
}
else
{
$this->lang->loadLanguageFile( 'public_profile', 'members' );
$acknowledge = $unAcknowledgedWarns['wl_id'];
}
}
}
/* No? Are they on mod queue? */
if ( $this->memberData['mod_posts'] )
{
$data = IPSMember::processBanEntry( $this->memberData['mod_posts'] );
if ( $data['date_end'] )
{
if ( time() >= $data['date_end'] )
{
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'mod_posts' => 0 ) ) );
}
else
{
$message = sprintf( $this->lang->words['warnings_modqueue_temp'], $this->lang->getDate( $data['date_end'], 'JOINED' ) );
}
}
else
{
$message = $this->lang->words['warnings_modqueue_perm'];
}
if ( $message )
{
$warn = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_mq<>0", 'order' => 'wl_date DESC', 'limit' => 1 ) );
if ( $warn['wl_id'] )
{
$moredetails = "<a href='javascript:void(0);' onclick='warningPopup( this, {$warn['wl_id']} )'>{$this->lang->words['warnings_moreinfo']}</a>";
}
}
}
/* How about our group? - Requires a new if in case mod queue restriction got just removed */
if ( empty($message) && $this->memberData['g_mod_preview'] )
{
/* Do we only limit for x posts/days? */
if ( $this->memberData['g_mod_post_unit'] )
{
if ( $this->memberData['gbw_mod_post_unit_type'] )
{
/* Days.. .*/
if ( $this->memberData['joined'] > ( time() - ( 86400 * $this->memberData['g_mod_post_unit'] ) ) )
{
$message = sprintf( $this->lang->words['ms_mod_q'] . ' ' . $this->lang->words['ms_mod_q_until'], $this->lang->getDate( $this->memberData['joined'] + ( 86400 * $this->memberData['g_mod_post_unit'] ), 'long' ) );
}
}
else
{
/* Posts */
if ( $this->memberData['posts'] < $this->memberData['g_mod_post_unit'] )
{
$message = sprintf( $this->lang->words['ms_mod_q'] . ' ' . $this->lang->words['ms_mod_q_until_posts'], $this->memberData['g_mod_post_unit'] - $this->memberData['posts'] );
}
}
}
else
{
/* No limit, but still checking moderating */
$message = $this->lang->words['ms_mod_q'];
}
}
/* Or just everyone? */
elseif ( $options['modAll'] and !$this->memberData['g_avoid_q'] )
{
$message = $this->lang->words['ms_mod_q'];
}
if ( $message )
{
$warningInfo = "{$message} {$moredetails}";
}
}
}
//-----------------------------------------
// Show the editor
//-----------------------------------------
$content = ( IPS_IS_AJAX ) ? str_replace( '&', '&amp;', $this->getContent() ) : $this->getContent();
$html = $this->registry->getClass('output')->getTemplate('editors')->editor( $fieldName, $content, $options, $this->getAutoSavedContent( $_autoSaveKeyOrig ), $warningInfo, $acknowledge );
}
return $html;
@@ -492,8 +735,8 @@ class classes_editor_composite
$return['key'] = $raw['eas_key'];
$return['updated'] = $raw['eas_updated'];
$return['raw'] = $raw['eas_content'];
$return['restore_rte'] = $this->switchContent( $return['raw'], false );
$return['restore_std'] = $this->switchContent( $return['raw'], true );
$return['restore_rte'] = $this->convertContent( nl2br($return['raw']), 'rte' );
$return['restore_std'] = $this->convertContent( nl2br($return['raw']), 'std' );
$return['updatedDate'] = $this->registry->getClass('class_localization')->getDate( $return['updated'], 'LONG' );
/* Now figure out previewable content */
@@ -592,33 +835,51 @@ class classes_editor_composite
{
IPSText::getTextClass('bbcode')->parse_html = false;
IPSText::getTextClass('bbcode')->parse_nl2br = 0;
IPSText::getTextClass('bbcode')->parse_smilies = true;
IPSText::getTextClass('bbcode')->parse_smilies = ( ! empty( $this->request['noSmilies'] ) ) ? false : true;
IPSText::getTextClass('bbcode')->parse_bbcode = true;
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
/* Default state for ACP */
if ( IN_ACP )
if ( IN_ACP && $this->getAllowHtml() === null )
{
IPSText::getTextClass('bbcode')->parse_html = true;
}
if ( $isRte )
{
$this->_isSwitchingFrom = 'std';
/* Assume RTE text has been sent in and we want BBCode */
$content = str_replace( '\\', '&#92;', $content ); # Makes manually entered < safe
$content = $this->_rteProcess( $content, IPS_EDITOR_NO_SANITIZE );
$content = IPSText::getTextClass('bbcode')->preEditParse( $content );
$content = $this->_stdPreShow( $content );
if ( ! $this->getAllowHtml() )
{
//IPSDebug::addLogMessage( $content, 'stdeditor', $_POST, true, true );
$content = $this->_rteProcess( $content, IPS_EDITOR_NO_SANITIZE );
//IPSDebug::addLogMessage( $content, 'stdeditor', false, true, false );
$content = IPSText::getTextClass('bbcode')->preEditParse( $content );
//IPSDebug::addLogMessage( $content, 'stdeditor', false, true, false );
$content = $this->_stdPreShow( $content );
//IPSDebug::addLogMessage( $content, 'stdeditor', false, true, false );
}
$content = str_replace( '&#92;', '\\', $content );
}
else
{
$this->_isSwitchingFrom = 'rte';
/* Assume BBCode has been sent in and we want RTE */
//$content = str_replace( '<', '&lt;', $content ); # Makes manually entered < safe
//$content = str_replace( '>', '&gt;', $content ); # Makes manually entered > safe
$content = $this->_rtePreShow( IPSText::getTextClass('bbcode')->convertForRTE( $this->_stdProcess( $content, IPS_EDITOR_NO_SANITIZE ) ), false, true );
if ( ! $this->getAllowHtml() )
{
//IPSDebug::addLogMessage( $content, 'editor', $_POST, true, true );
$content = $this->_stdProcess( $content, IPS_EDITOR_NO_SANITIZE );
//IPSDebug::addLogMessage( $content, 'editor', false, true, false );
$content = IPSText::getTextClass('bbcode')->convertForRTE( $content );
//IPSDebug::addLogMessage( $content, 'editor', false, true, false );
$content = $this->_rtePreShow( $content, false, true );
//IPSDebug::addLogMessage( $content, 'editor', false, true, false );
}
}
$this->_isSwitchingFrom = null;
@@ -638,9 +899,9 @@ class classes_editor_composite
$t = str_replace( array( "\r\n", "\r" ), "\n", $t );
IPSDebug::fireBug( 'info', array( 'Start (std): ' . nl2br($t) ) );
$t = IPSText::decodeNamedHtmlEntities( $t );
$t = IPSText::decodeNamedHtmlEntities( $t );
$t = str_replace( '&#33;', '!', $t );
$t = str_replace( '&#34;', '"', $t );
$t = str_replace( '&quot;', '"', $t );
@@ -654,6 +915,13 @@ class classes_editor_composite
$t = str_replace( '&#92;', '\\', $t );
$t = str_replace( '&#092;', '\\', $t );
$t = str_replace( '&#160;', ' ', $t );
$t = str_replace( '&#91;', '[', $t );
$t = str_replace( '&#93;', ']', $t );
$t = str_replace( '&#123;', '{', $t );
$t = str_replace( '&#125;', '}', $t );
$t = str_replace( '&nbsp;', ' ', $t );
$t = str_replace( "\t" , ' ', $t );
/* We replace \ to 092 so convert it back */
$t = str_replace( '&amp;#092;', '\\', $t );
@@ -664,9 +932,17 @@ class classes_editor_composite
}
$t = str_replace( '</textarea', '&lt;textarea', $t );
$t = str_replace( '<script' , '&lt;script' , $t );
$t = $this->_allowNonUtf8CharsWhenNotUsingUtf8Doc( $t );
/* Sect breaks on std editor @link http://community.invisionpower.com/tracker/issue-37498-gets-converted-into-sect%3B-when-editing-a-post/ */
$t = $this->_convertNumericEntityToNamed( $t );
/* We make paths safe in clean globals */
$t = str_replace( '&#46;&#46;/', '../', $t );
IPSDebug::fireBug( 'info', array( 'End (std): ' . nl2br($t) ) );
return $t;
@@ -682,13 +958,15 @@ class classes_editor_composite
* @return string Text ready for editor
*/
public function _rtePreShow( $t, $encodeEntities=false )
{
{
IPSDebug::fireBug( 'info', array( 'Start (rte): ' . nl2br($t) ) );
/* Trim and remove comments */
$t = preg_replace( '#\<\!\-\-(.+?)\-\-\>#is', "", $t );
$t = rtrim($t);
/* Parsing can kill img URLs as they are made 'safe' to not parse */
$t = str_replace( 'http&#58;', 'http:', $t );
/* Convert single/double quotes */
if ( strtolower(IPS_DOC_CHAR_SET) != 'utf-8' )
{
@@ -721,7 +999,7 @@ class classes_editor_composite
$t = str_replace( '&#10;', '<br />', $t );
/* AJAX content is inserted into editor via insertText which does not parse entities as they would normally display */
if( ! IPS_IS_AJAX )
if ( ! IPS_IS_AJAX )
{
$t = str_replace( '&', '&amp;', $t );
}
@@ -742,8 +1020,8 @@ class classes_editor_composite
$t = str_replace( "&lt;#IMG_DIR#&gt;", "<#IMG_DIR#>", $t );
$t = str_replace( "&lt;#EMO_DIR#&gt;", "<#EMO_DIR#>", $t );
/* Convert multiple spaces */
$t = str_replace( " ", "&nbsp;&nbsp;", $t );
/* Convert multiple spaces (Causes more issues than it fixes) */
//$t = str_replace( " ", "&nbsp;&nbsp;", $t );
/* Fix up lists */
$t = str_replace( '<br /></li>', '</li>', $t );
@@ -788,7 +1066,15 @@ class classes_editor_composite
}
IPSDebug::fireBug( 'info', array( 'End (rte): ' . $t ) );
if ( $this->getAllowHtml() )
{
$t = str_replace( '&amp;', '&', $t );
$t = str_replace( '&gt;', '>', $t );
$t = str_replace( '&lt;', '<', $t );
$t = str_replace( '&nbsp;', ' ', $t );
}
return $t;
}
@@ -818,7 +1104,12 @@ class classes_editor_composite
$content = preg_replace( '#^([ ]+?)\n#m', "\n", $content );
return trim( $this->_clean( $content, $NO_SANITIZE, false ) );
/* We make paths safe in clean globals */
$content = str_replace( '&#46;&#46;/', '../', $content );
$content = trim( $this->_clean( $content, $NO_SANITIZE, false ) );
return $content;
}
/**
@@ -849,7 +1140,7 @@ class classes_editor_composite
* <p>More data</p>
* <p><br /></p>
*/
if ( self::IPS_P_MODE )
if ( self::IPS_P_MODE && ! $this->getAllowHtml() )
{
/* Tidy up first */
$content = str_replace( '<div' , '<p' , $content );
@@ -862,22 +1153,27 @@ class classes_editor_composite
/* Before we content/strip newlines, lets make code safe */
$content = $this->_recurseAndParse( 'pre', $content, "_parsePreTag" );
//-----------------------------------------
// Fix up tabs/spaces
//-----------------------------------------
$content = str_replace( '&nbsp;&nbsp;&nbsp;&nbsp;', "{'tab'}", $content );
$content = str_replace( '&nbsp;', ' ', $content );
/* looks to be non RTE content that has ended up there */
if ( ! strstr( $content, '<br' ) && ! strstr( $content, '<p' ) && strstr( $content, "\n" ) )
if ( ! $this->getAllowHtml() )
{
$content = str_replace( "\n", "<br />", $content );
}
else
{
$content = str_replace( "\n", "", $content );
$content = str_replace( '&nbsp;&nbsp;&nbsp;&nbsp;', "{'tab'}", $content );
$content = str_replace( "\t", "{'tab'}", $content );
$content = str_replace( '&nbsp;', ' ', $content );
/* looks to be non RTE content that has ended up there */
if ( ! strstr( $content, '<br' ) && ! strstr( $content, '<p' ) && strstr( $content, "\n" ) )
{
$content = str_replace( "\n", "<br />", $content );
}
else
{
$content = str_replace( "\n", "", $content );
}
}
//-----------------------------------------
@@ -906,8 +1202,11 @@ class classes_editor_composite
// WYSI-Weirdness #1: BR tags to \n
//-----------------------------------------
$content = preg_replace( '#<br([^>]+?)>#', "<br />", $content );
$content = str_ireplace( array( "<br>", "<br />" ), "\n", $content );
if ( ! $this->getAllowHtml() )
{
$content = preg_replace( '#<br([^>]+?)>#', "<br />", $content );
$content = str_ireplace( array( "<br>", "<br />" ), "\n", $content );
}
$content = trim( $content );
@@ -952,7 +1251,10 @@ class classes_editor_composite
// WYSI-Weirdness #3: Headline tags
//-----------------------------------------
$content = preg_replace( "#<(h[0-9])(?:[^>]+?)?>(.+?)</\\1>#is", "\n[b]\\2[/b]\n", $content );
if ( ! $this->getAllowHtml() )
{
$content = preg_replace( "#<(h[0-9])(?:[^>]+?)?>(.+?)</\\1>#is", "\n[b]\\2[/b]\n", $content );
}
//-----------------------------------------
// WYSI-Weirdness #4: Font tags
@@ -993,7 +1295,7 @@ class classes_editor_composite
$content = preg_replace( '#\[img\](/)?public/style_(emoticons|images)#i', '[img]' . $this->settings['board_url'] . '/public/style_' . '\\2', $content );
//-----------------------------------------
// Clean up whitespace between lis
// Clean up whitespace between lists
//-----------------------------------------
$content = preg_replace( '#<li>\s+?(\S)#', '<li>\\1', $content );
@@ -1005,37 +1307,40 @@ class classes_editor_composite
// to make sure we get the nested ones
//-----------------------------------------
$content = $this->_recurseAndParse( 'b' , $content, "_parseSimpleTag", 'b' );
$content = $this->_recurseAndParse( 'u' , $content, "_parseSimpleTag", 'u' );
$content = $this->_recurseAndParse( 'strong' , $content, "_parseSimpleTag", 'b' );
$content = $this->_recurseAndParse( 'i' , $content, "_parseSimpleTag", 'i' );
$content = $this->_recurseAndParse( 'em' , $content, "_parseSimpleTag", 'i' );
$content = $this->_recurseAndParse( 'strike' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 'del' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 's' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 'blockquote', $content, "_parseSimpleTag", 'indent' );
$content = $this->_recurseAndParse( 'sup' , $content, "_parseSimpleTag", 'sup' );
$content = $this->_recurseAndParse( 'sub' , $content, "_parseSimpleTag", 'sub' );
//-----------------------------------------
// More complex tags
//-----------------------------------------
$content = $this->_recurseAndParse( 'a' , $content, "_parseAnchorTag" );
$content = $this->_recurseAndParse( 'font' , $content, "_parseFontTag" );
$content = $this->_recurseAndParse( 'div' , $content, "_parseDivTag" );
$content = $this->_recurseAndParse( 'p' , $content, "_parseParagraphTag" );
$content = $this->_recurseAndParse( 'span' , $content, "_parseSpanTag" );
if ( ! $this->getAllowHtml() )
{
$content = $this->_recurseAndParse( 'b' , $content, "_parseSimpleTag", 'b' );
$content = $this->_recurseAndParse( 'u' , $content, "_parseSimpleTag", 'u' );
$content = $this->_recurseAndParse( 'strong' , $content, "_parseSimpleTag", 'b' );
$content = $this->_recurseAndParse( 'i' , $content, "_parseSimpleTag", 'i' );
$content = $this->_recurseAndParse( 'em' , $content, "_parseSimpleTag", 'i' );
$content = $this->_recurseAndParse( 'strike' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 'del' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 's' , $content, "_parseSimpleTag", 's' );
$content = $this->_recurseAndParse( 'blockquote', $content, "_parseSimpleTag", 'indent' );
$content = $this->_recurseAndParse( 'sup' , $content, "_parseSimpleTag", 'sup' );
$content = $this->_recurseAndParse( 'sub' , $content, "_parseSimpleTag", 'sub' );
/* Possibility of preceeding \n because of P tag */
$content = trim( $content );
//-----------------------------------------
// Lists
//-----------------------------------------
$content = $this->_recurseAndParse( 'ol' , $content, "_parseListTag" );
$content = $this->_recurseAndParse( 'ul' , $content, "_parseListTag" );
//-----------------------------------------
// More complex tags
//-----------------------------------------
$content = $this->_recurseAndParse( 'a' , $content, "_parseAnchorTag" );
$content = $this->_recurseAndParse( 'font' , $content, "_parseFontTag" );
$content = $this->_recurseAndParse( 'div' , $content, "_parseDivTag" );
$content = $this->_recurseAndParse( 'p' , $content, "_parseParagraphTag" );
$content = $this->_recurseAndParse( 'span' , $content, "_parseSpanTag" );
/* Possibility of preceeding \n because of P tag */
$content = trim( $content );
//-----------------------------------------
// Lists
//-----------------------------------------
$content = $this->_recurseAndParse( 'ol' , $content, "_parseListTag" );
$content = $this->_recurseAndParse( 'ul' , $content, "_parseListTag" );
}
//-----------------------------------------
// WYSI-Weirdness #9: Fix up para tags
@@ -1047,7 +1352,10 @@ class classes_editor_composite
// WYSI-Weirdness #10: Random junk
//-----------------------------------------
$content = str_ireplace( array( "<a>", "</a>", "</li>" ), "", $content );
if ( ! $this->getAllowHtml() )
{
$content = str_ireplace( array( "<a>", "</a>", "</li>" ), "", $content );
}
//-----------------------------------------
// WYSI-Weirdness #11: Fix up list stuff
@@ -1059,18 +1367,24 @@ class classes_editor_composite
// WYSI-Weirdness #11.1: Safari badness
//-----------------------------------------
$content = str_replace( "</div>", "", $content );
if ( ! $this->getAllowHtml() )
{
$content = str_replace( "</div>", "", $content );
/* Sometimes, unclosed P tags remain if text is copied and pasted directly */
$content = preg_replace( '#<(p|div|ul|li)([^\>]+?)\>#is', '', $content );
}
/* Sometimes, unclosed P tags remain if text is copied and pasted directly */
$content = preg_replace( '#<(p|div|ul|li)([^\>]+?)\>#is', '', $content );
//-----------------------------------------
// WYSI-Weirdness #12: Convert rest to HTML
//-----------------------------------------
$content = str_replace( '&lt;' , '<', $content );
$content = str_replace( '&gt;' , '>', $content );
if ( ! $this->getAllowHtml() )
{
$content = str_replace( '&lt;' , '<', $content );
$content = str_replace( '&gt;' , '>', $content );
}
//-----------------------------------------
// WYSI-Weirdness #13: Remove useless tags
//-----------------------------------------
@@ -1078,10 +1392,10 @@ class classes_editor_composite
/* Remove embedded stuffs */
$content = preg_replace( '#\[(center|right|left)\]\[\1\]#i', '[\1]', $content );
$content = preg_replace( '#\[/(center|right|left)\]\[/\1\]#i', '[/\1]', $content );
while( preg_match( '#\[(url|img|b|u|i|s|email|list|indent|right|left|center)\](\s+?)?\[/\1\]#is', $content ) )
while( preg_match( '#\<(b|u|i|s|li)\>(\s+?)?\</\1\>#is', $content ) )
{
$content = preg_replace( '#\[(url|img|b|u|i|s|email|list|indent|right|left|center)\](\s+?)?\[/\1\]#is', "", $content );
$content = preg_replace( '#\<(b|u|i|s|li)\>(\s+?)?\</\1\>#is', "", $content );
}
//-----------------------------------------
@@ -1103,12 +1417,16 @@ class classes_editor_composite
$content = preg_replace( '#(http|https):\/\/index.php(.*?)#is', $this->settings['board_url'].'/index.php\\2', $content );
$content = preg_replace( '#\[url=[\'\"]index.php(.*?)[\"\']#is', "[url=\"".$this->settings['board_url'].'/index.php\\1"', $content );
/* Fix up incorrect tags outside of quotes */
$content = preg_replace( '#\[(b|u|s)\](\[quote)#' , '\2[\1]' , $content );
$content = preg_replace( '#(\[/quote])\[/(b|u|s)\]#', '[/\2]\1', $content );
//-----------------------------------------
// Replace tabs
//-----------------------------------------
#IPSDebug::addLogMessage( $content, 'editor', false, true );
$content = str_replace( "{'tab'}", "\t", $content );
//-----------------------------------------
// Now call the santize routine to make
// html and nasties safe. VITAL!!
@@ -1174,12 +1492,13 @@ class classes_editor_composite
protected function _parseListTag( $tag, $between_text, $opening_tag, $parse_tag )
{
$list_type = trim( preg_replace( '#"?list-style-type:\s+?([\d\w\_\-]+);?"?#si', '\\1', $this->_getValueOfOption( 'style', $opening_tag ) ) );
$css = $this->_getValueOfOption( 'class', $opening_tag );
//-----------------------------------------
// Set up a default...
//-----------------------------------------
if ( ! $list_type and $tag == 'ol' )
if ( ( stristr( $css, ' decimal' ) ) OR ! $list_type and $tag == 'ol' )
{
$list_type = 'decimal';
}
@@ -1551,15 +1870,16 @@ class classes_editor_composite
protected function _parseStyles( $opening_tag, &$start_tags, &$end_tags )
{
$style_list = array(
array('tag' => 'color' , 'rx' => '(?<![\w\-])color:\s*([^;]+);?' , 'match' => 1),
array('tag' => 'font' , 'rx' => 'font-family:\s*([^;]+);?' , 'match' => 1),
array('tag' => 'size' , 'rx' => 'font-size:\s*(.+);?' , 'match' => 1),
array('tag' => 'b' , 'rx' => 'font-weight:\s*(bold);?'),
array('tag' => 'i' , 'rx' => 'font-style:\s*(italic);?'),
array('tag' => 'u' , 'rx' => 'text-decoration:\s*(underline);?'),
array('tag' => 'left' , 'rx' => 'text-align:\s*(left);?'),
array('tag' => 'center', 'rx' => 'text-align:\s*(center);?'),
array('tag' => 'right' , 'rx' => 'text-align:\s*(right);?'),
array('tag' => 'color' , 'rx' => '(?<![\w\-])color:\s*([^;]+);?' , 'match' => 1),
array('tag' => 'font' , 'rx' => 'font-family:\s*([^;]+);?' , 'match' => 1),
array('tag' => 'size' , 'rx' => 'font-size:\s*(.+);?' , 'match' => 1),
array('tag' => 'b' , 'rx' => 'font-weight:\s*(bold);?'),
array('tag' => 'i' , 'rx' => 'font-style:\s*(italic);?'),
array('tag' => 'u' , 'rx' => 'text-decoration:\s*(underline);?'),
array('tag' => 'left' , 'rx' => 'text-align:\s*(left);?'),
array('tag' => 'center' , 'rx' => 'text-align:\s*(center);?'),
array('tag' => 'right' , 'rx' => 'text-align:\s*(right);?'),
array('tag' => 'background' , 'rx' => 'background-color:\s*([^;]+);?', 'match' => 1),
);
//-----------------------------------------
@@ -1939,7 +2259,9 @@ class classes_editor_composite
// ckeditor should have a more universal formatting so let's go with the one regex now
//if( $option == 'style' AND ( $this->memberData['userAgentKey'] == 'safari' OR $this->memberData['userAgentKey'] == 'chrome' ) )
//{
preg_match( "#{$option}(\s*?)?\=(\s*?)?[\"']?(.+?)([\"']|$|>)#is", $text, $matches );
/* @link http://community.invisionpower.com/tracker/issue-37385-editor-removes-apostrophe-from-url/
tightened up regex end ([\"'](\s|$|>)) */
preg_match( "#{$option}(\s*?)?\=(\s*?)?[\"']?(.+?)([\"'](\s|$|>))#is", $text, $matches );
//}
//else
//{
@@ -2063,7 +2385,7 @@ class classes_editor_composite
{
$image_set = $this->DB->buildAndFetch( array( 'select' => 'set_image_dir, set_emo_dir', 'from' => 'skin_collections', 'where' => 'set_is_default=1' ) );
return $image_set['set_image_dir'];
return $image_set['set_emo_dir'];
}
else
{
@@ -2095,6 +2417,11 @@ class classes_editor_composite
return "";
}
if ( $this->getAllowHtml() )
{
return $t;
}
if ( IPS_DOC_CHAR_SET == 'UTF-8' || $this->_isSwitchingFrom == 'std' )
{
$t = IPSText::decodeNamedHtmlEntities( $t );
@@ -2129,11 +2456,16 @@ class classes_editor_composite
$t = str_replace( "&#34;", '&quot;', $t );
$t = str_replace( "&#38;", '&amp;', $t );
$t = str_replace( "&#160;", ' ', $t );
/* Make tags safe */
$t = preg_replace( '#\{(style_image(?:s)?_url)\}#i', '&#123;\1&#125;', $t );
$t = str_replace( "\n", "<br />", $t );
$t = $this->_allowNonUtf8CharsWhenNotUsingUtf8Doc( $t );
$t = $this->_convertNumericEntityToNamed( $t );
// print header('Content-type: text/plain'); print $t; exit();
return $t;
}
@@ -2186,7 +2518,7 @@ class classes_editor_composite
$emoString = '';
$smilie_id = 0;
$total = 0;
foreach( ipsRegistry::cache()->getCache('emoticons') as $elmo )
{
if ( $elmo['emo_set'] != $emoDir )
@@ -2249,7 +2581,7 @@ class classes_editor_composite
* @return string Converted string
*/
protected function _allowNonUtf8CharsWhenNotUsingUtf8Doc( $string )
{
{
/* If we're not using UTF-8, lets try and handle encoded data. */
if ( IPS_DOC_CHAR_SET != 'UTF-8' )
{
@@ -2280,6 +2612,37 @@ class classes_editor_composite
return $string;
}
/**
* Converts numeric entities to their named equivalents
*
* @param string
* @return string
*/
protected function _convertNumericEntityToNamed( $string )
{
/* If we're not using UTF-8, lets try and handle encoded data. */
if ( IPS_DOC_CHAR_SET != 'UTF-8' )
{
/* First, convert any left over &acute; style chars */
preg_match_all( '/&#([0-9]{3,8});/', $string, $matches );
foreach( $matches[1] as $word )
{
if ( $word > 127 )
{
$converted = str_replace( '&', '&amp;', $this->_convertEntity( array( 1 => $word ), true ) );
if ( $converted )
{
$string = str_replace( '&#' . $word . ';', $converted, $string );
}
}
}
}
return $string;
}
/**
* Function to convert named entities to numeric entities
*
@@ -2287,7 +2650,7 @@ class classes_editor_composite
* @return string
* @link http://www.lazycat.org/php-convert-entities.php
*/
protected function _convertEntity( $matches )
protected function _convertEntity( $matches, $flip=false )
{
static $table = array(/*'quot' => '&#34;','amp' => '&#38;','lt' => '&#60;','gt' => '&#62;',*/'OElig' => '&#338;','oelig' => '&#339;','Scaron' => '&#352;','scaron' => '&#353;','Yuml' => '&#376;',
'circ' => '&#710;','tilde' => '&#732;','ensp' => '&#8194;','emsp' => '&#8195;','thinsp' => '&#8201;','zwnj' => '&#8204;','zwj' => '&#8205;','lrm' => '&#8206;','rlm' => '&#8207;',
@@ -2316,7 +2679,16 @@ class classes_editor_composite
'aring' => '&#229;','aelig' => '&#230;','ccedil' => '&#231;','egrave' => '&#232;','eacute' => '&#233;','ecirc' => '&#234;','euml' => '&#235;','igrave' => '&#236;','iacute' => '&#237;',
'icirc' => '&#238;','iuml' => '&#239;','eth' => '&#240;','ntilde' => '&#241;','ograve' => '&#242;','oacute' => '&#243;','ocirc' => '&#244;','otilde' => '&#245;','ouml' => '&#246;',
'divide' => '&#247;','oslash' => '&#248;','ugrave' => '&#249;','uacute' => '&#250;','ucirc' => '&#251;','uuml' => '&#252;','yacute' => '&#253;','thorn' => '&#254;','yuml' => '&#255;' );
if ( $flip === true )
{
$tmp = array_flip( $table );
$lookup = '&#' . $matches[1] . ';';
return isset( $tmp[ $lookup ] ) ? '&' . $tmp[ $lookup ] . ';' : $lookup;
}
return isset( $table[ $matches[1] ] ) ? $table[ $matches[1] ] : '&' . $matches[1] . ';';
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,742 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Parse Incoming Emails
* Last Updated: $Date: 2012-06-01 11:18:06 -0400 (Fri, 01 Jun 2012) $
* </pre>
*
* @author $Author: mark $
* @copyright © 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since 25th June 2010
* @version $Revision: 10854 $
*/
class incomingEmail
{
/**
* Params
*/
public $to = '';
public $from = '';
public $subject = '';
public $cc = '';
public $message = '';
public $original_message = '';
public $raw = '';
public $alternative = '';
public $attachments = array();
/**
* Debug Mode
*/
protected $debug_mode = FALSE;
/**
* Preferred order for alterative parts
*/
protected $alternativePrefs = array(
'multipart' => array(), // Multipart has to come first as it's the only one which will include attachments sometimes
'text' => array(),
);
/**
* Constructor
*/
protected function __construct()
{
/* Init objects */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
/* Fix up the base URL */
$this->settings['base_url'] = preg_replace( '/^(.+\/).+?\?(.*?)$/', '$1index.php?$2', $this->settings['base_url'] );
/* Get 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;
}
/* Set our preferred format */
if ( $this->settings['incoming_emails_textpref'] == 'html' )
{
$this->alternativePrefs['text'][] = 'html';
$this->alternativePrefs['text'][] = 'plain';
}
else
{
$this->alternativePrefs['text'][] = 'plain';
$this->alternativePrefs['text'][] = 'html';
}
}
/**
* Main Parse Method
*
* @param string Raw email contents
* @param array Any headers to override
* @param bool Can pass true to not actually route
*/
public static function parse( $email, $override=array(), $doNotRoute=FALSE )
{
$obj = new self();
$obj->raw = $email;
//-----------------------------------------
// Deconstruct it
//-----------------------------------------
// It raises strict warnings
@error_reporting( E_NONE );
@ini_set( 'display_errors', 'off' );
require_once ( IPS_KERNEL_PATH . 'PEAR/Mail/mimeDecode.php' );/*noLibHook*/
$decoder = new Mail_mimeDecode( $email );
$mail = $decoder->decode( array(
'include_bodies' => TRUE,
'decode_bodies' => TRUE,
'decode_headers' => TRUE,
) );
//--------------------------------------
// Parse Headers
//--------------------------------------
/* To */
if ( isset( $override['to'] ) )
{
$obj->to = $override['to'];
}
else
{
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[] = htmlentities( $matches[1] );
}
else
{
$to[] = htmlentities( trim( $_to, '<>' ) );
}
}
$obj->to = implode( ',', $to );
}
/* From */
if ( isset( $override['from'] ) )
{
$obj->from = $override['from'];
}
else
{
if ( preg_match( "/.+? <(.+?)>/", $mail->headers['from'], $matches ) )
{
$obj->from = htmlentities( $matches[1] );
}
else
{
$obj->from = htmlentities( trim( $mail->headers['from'], '<>' ) );
}
}
/* Subject */
if ( isset( $override['subject'] ) )
{
$obj->subject = $override['subject'];
}
else
{
$obj->subject = ( (bool) trim( $mail->headers['subject'] ) ) ? $mail->headers['subject'] : '(No Subject)';
$obj->subject = htmlentities( $obj->subject );
}
/* CC */
$mail->headers['cc'] = preg_replace( '/".+?" <(.+?)>/', '$1', $mail->headers['cc'] );
if ( strpos( $mail->headers['cc'], ',' ) === FALSE )
{
$mail->headers['cc'] = array( $mail->headers['cc'] );
}
else
{
$mail->headers['cc'] = explode( ',', $mail->headers['cc'] );
}
foreach ( $mail->headers['cc'] as $_cc )
{
if ( preg_match( "/.+? <(.+?)>/", $_cc, $matches ) )
{
$cc[] = htmlentities( $matches[1] );
}
else
{
$cc[] = htmlentities( trim( $_cc, '<> ' ) );
}
}
$obj->cc = str_replace( array( '&gt;', '&lt;' ), '', implode( ',', $cc ) );
//-----------------------------------------
// Ignore?
//-----------------------------------------
if ( !$obj->debug_mode )
{
$escapedFrom = $obj->DB->addSlashes( $obj->from );
$log = $obj->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_incoming_email_log', 'where' => "log_email='{$escapedFrom}'" ) );
if ( $log['log_id'] )
{
$oneMinuteAgo = time() - 60;
if ( $log['log_time'] > $oneMinuteAgo )
{
$ignore = TRUE;
}
$obj->DB->update( 'core_incoming_email_log', array( 'log_time' => time() ), "log_id={$log['log_id']}" );
if ( $ignore )
{
return;
}
}
else
{
$obj->DB->insert( 'core_incoming_email_log', array( 'log_email' => $obj->from, 'log_time' => time() ) );
}
}
//-----------------------------------------
// Now destruct the message
//-----------------------------------------
$obj->message = '';
$obj->_parsePart( $mail );
//-----------------------------------------
// Purify It
//-----------------------------------------
// &nbsp; sometimes breaks
$obj->message = str_replace( '&nbsp;', ' ', $obj->message );
/* Load */
require_once( IPS_KERNEL_PATH . 'HTMLPurifier/HTMLPurifier.auto.php' );
$config = HTMLPurifier_Config::createDefault();
/* Set Configuration */
$config->set( 'AutoFormat.Linkify', TRUE );
$config->set( 'Core.Encoding', IPS_DOC_CHAR_SET );
$config->set( 'HTML.TargetBlank', TRUE );
$config->set( 'URI.Munge', ipsRegistry::getClass('output')->buildUrl('app=nexus&module=support&section=redirect&url=%s&key=%t&resource=%r', 'public' ) );
$config->set( 'URI.MungeResources', TRUE );
$config->set( 'URI.MungeSecretKey', md5( ipsRegistry::$settings['sql_pass'] . ipsRegistry::$settings['board_url'] . ipsRegistry::$settings['sql_database'] ) );
/* Purify */
$purifier = new HTMLPurifier( $config );
$obj->message = $purifier->purify( $obj->message );
//-----------------------------------------
// Route
//-----------------------------------------
if ( $doNotRoute )
{
return $obj;
}
$routed = FALSE;
/* Try our routing criteria */
$obj->DB->build( array( 'select' => '*', 'from' => 'core_incoming_emails' ) );
$obj->DB->execute();
while ( $row = $obj->DB->fetch() )
{
// What are we looking for?
switch ( $row['rule_criteria_field'] )
{
case 'to':
$analyse = $obj->to;
break;
case 'from':
$analyse = $obj->from;
break;
case 'sbjt':
$analyse = $obj->subject;
break;
case 'body':
$analyse = $obj->message;
break;
}
// Does it match?
$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 it matches, give to the app
if ( $match )
{
$routed = true;
if ( $row['rule_app'] != '--' )
{
$appdir = IPSLib::getAppDir( $row['rule_app'] );
if ( is_file( $appdir . '/extensions/incomingEmails.php' ) )
{
$class = 'incomingEmails_' . $row['rule_app'];
require_once( $appdir . '/extensions/incomingEmails.php' );/*noLibHook*/
$class = new $class;
$class->process( $obj );
}
}
break;
}
}
/* Still here? Try all our apps */
if ( !$routed )
{
foreach ( ipsRegistry::$applications as $app )
{
$file = IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/incomingEmails.php';
if ( file_exists( $file ) )
{
require_once( $file );
$class = 'incomingEmails_' . $app['app_directory'];
$i = new $class;
if ( $routed = $i->handleUnrouted( $obj ) )
{
break;
}
}
}
}
/* STILL Here? Throw the unrouted message */
if ( !$routed )
{
$unroutedMessage = @file_get_contents( DOC_IPS_ROOT_PATH . 'interface/email/unrouted.txt' );
if ( $unroutedMessage )
{
IPSText::getTextClass('email')->to = $obj->from;
IPSText::getTextClass('email')->from = $obj->to;
IPSText::getTextClass('email')->subject = "Re: {$obj->subject}";
IPSText::getTextClass('email')->message = nl2br( $unroutedMessage );
IPSText::getTextClass('email')->setHtmlEmail( TRUE );
IPSText::getTextClass( 'email' )->sendMail();
}
}
}
/**
* Parse a "part"
*
* @param stdClass As returned by mailMime_decode
*/
protected function _parsePart( $part )
{
/* Some clients use uppercase, but we check by lowercase */
$part->ctype_primary = strtolower( $part->ctype_primary );
$part->ctype_secondary = strtolower( $part->ctype_secondary );
/* What is this? */
switch ( $part->ctype_primary )
{
/* Multipart - means there's more than one part to this part */
case 'multipart':
// "Alternative" means there's more than one way to interpret this part, usually means we have plain text and HTML varients
if ( $part->ctype_secondary == 'alternative' )
{
// First, check if we have html and plaintext
if ( !$this->alternative )
{
$haveHtml = false;
$havePlain = false;
foreach ( $part->parts as $p )
{
if ( $p->ctype_primary == 'text' )
{
if ( $p->ctype_secondary == 'html' )
{
$haveHtml = true;
}
elseif ( $p->ctype_secondary == 'plain' )
{
$havePlain = true;
}
}
}
}
// This means we need to decide which of the parts we prefer
$preferredPart = array_shift( $part->parts );
foreach ( $part->parts as $p )
{
if ( $this->_isBetter( $preferredPart, $p ) )
{
$preferredPart = $p;
}
}
// What did we choose?
if ( !$this->alternative and $haveHtml and $havePlain )
{
if ( $preferredPart->ctype_secondary == 'html' )
{
$this->alternative = 'h';
}
elseif ( $preferredPart->ctype_secondary == 'html' )
{
$this->alternative = 'p';
}
}
return $this->_parsePart( $preferredPart );
}
// Otherwise, parse all parts
foreach ( $part->parts as $p )
{
$this->_parsePart( $p );
}
return;
/* Text */
case 'text':
$body = $part->body;
$this->original_message .= $body;
//-----------------------------------------
// Add <br /> tags
//-----------------------------------------
if ( $part->ctype_secondary != 'html' )
{
$body = nl2br( $body );
}
//-----------------------------------------
// Convert the charset if necessary
//-----------------------------------------
if ( isset( $part->ctype_parameters['charset'] ) and $part->ctype_parameters['charset'] != IPS_DOC_CHAR_SET )
{
// Sometimes the charset will be "xx-ascii" which isn't what we want
if ( strpos( $part->ctype_parameters['charset'], 'ascii' ) !== FALSE )
{
//$part->ctype_parameters['charset'] = 'iso-8859-1';
}
// Convert
//$body = IPSText::convertCharsets( $body, $part->ctype_parameters['charset'], IPS_DOC_CHAR_SET );
}
//-----------------------------------------
// Parse > style quotes
//-----------------------------------------
$quoteLevel = 0;
$quotableLine = '';
foreach ( explode( "<br />", $body ) as $k => $line )
{
$line = trim( $line );
// We only need to check for opening/closing quotes if this line actually has content
if ( $line )
{
// If this line starts with less >s than we're expecting, add a close quote tag
// Note we strip whitespace when doing this check as sometimes you'll get ">>>" and other times "> > >"
if ( substr( str_replace( ' ', '', $line ), 0, $quoteLevel ) != str_repeat( '>', $quoteLevel ) )
{
$quoteLevel--;
$line = substr( $line, $quoteLevel );
$line .= '[/quote]<br />';
}
else
{
// Strip out the >s that we're expecting
// Note this has to use the regex as sometimes you'll get ">>>" and other times "> > >"
$line = trim( preg_replace( '/^(>\s?){' . $quoteLevel . '}/', '', $line ) );
// If, after stripping the expected number of >s, the line still starts with a >, then open a quote tag
if ( substr( $line, 0, 1 ) == '>' )
{
$quoteLevel++;
$line = substr( $line, 1 );
// If we have content to add into the tag, do that, otherwise, a blank quote is fine
if ( $quotableLine )
{
$this->message = substr( $this->message, 0, strrpos( $this->message, $quotableLine ) );
$this->message .= "[quote collapse='{$quotableLine}']";
}
else
{
$this->message .= "[quote collapse='1']";
}
}
}
// Save the content of this line so that if a quote starts on the next line, we can put it in the header of that quote
// Only do this if the line ends with a colon (i.e. "On x, y wrote:") and it doesn't contain any quote tags we've added
$quotableLine = '';
if ( substr( $line, -1 ) == ':' and strpos( $line, '[' ) === FALSE )
{
$quotableLine = $line;
}
}
$this->message .= $line . '<br />';
}
if ( $quoteLevel )
{
for ( $i = 0; $i < $quoteLevel; $i++ )
{
$this->message .= '[/quote]';
}
}
//-----------------------------------------
// Parse HTML block quotes
//-----------------------------------------
/* Loop */
preg_match_all( '/<blockquote.+?>/s', $this->message, $matches );
while ( !empty( $matches ) and !empty( $matches[0] ) )
{
$m = $matches[0][0];
// Get all the content before the quote
$stripped = substr( $this->message, 0, strpos( $this->message, $m ) );
// Knock off any breaks or closed divs after it
$stripped = preg_replace( '/<br.+?>/s', '', $stripped );
$stripped = str_replace( '</div>', '', $stripped );
// Now scan back until we hit some other html
$pos = strrpos( $stripped, '>' ) + 1;
$stripped = trim( substr( $stripped, $pos ) );
// If it's an acceptable header, use it
if ( substr( $stripped, -1, 1 ) == ':' )
{
// Chop it out
$this->message = substr_replace( $this->message, '', strpos( $this->message, $stripped ), strlen( $stripped ) );
// We have to encode the header so future tags don't replace it
$stripped = '{{QUOTE-ENCODE:' . base64_encode( $stripped ) . '}}';
// Replace the blockquote
$this->message = substr_replace( $this->message, "[quote collapse='{$stripped}']", strpos( $this->message, $m ), strlen( $m ) );
}
else
{
// Replace the blockquote
$this->message = substr_replace( $this->message, "[quote collapse='1']", strpos( $this->message, $m ), strlen( $m ) );
}
// Do the scan again
preg_match_all( '/<blockquote.+?>/s', $this->message, $matches );
}
/* Decode the quote headers we made */
$this->message = preg_replace_callback( '/{{QUOTE-ENCODE:(.+?)}}/', create_function( '$m', 'return base64_decode( $m[1] );' ), $this->message );
/* Add in closing [/quote] tags */
$this->message = preg_replace( '/<\/blockquote>/', '[/quote]', $this->message );
/* Check we haven't ended up with any blank quotes */
preg_match_all( '/\[quote.+?\](.+?)\[\/quote\]/s', $this->message, $matches );
foreach ( $matches[0] as $k => $m )
{
if ( !trim( strip_tags( $matches[1][$k] ) ) )
{
$this->message = str_replace( $m, '', $this->message );
}
}
//-----------------------------------------
// Quote out "Forwarded Message"
//-----------------------------------------
if ( preg_match( '/-{10,}\s+(.+?)\s-{10,}/', $this->message, $matches ) )
{
$this->message = str_replace( $matches[0], "[quote collapse='{$matches[1]}']", $this->message );
$this->message .= '[/quote]';
}
return;
/* Attachments */
default:
$mime = "{$part->ctype_primary}/{$part->ctype_secondary}";
$content = "{ATTACHMENT WITH INCOMPATIBLE MIME TYPE: {$mime}}";
if ( isset( $this->types[ $mime ] ) )
{
foreach ( $this->types[ $mime ] as $data )
{
$name_parts = explode( '.', $part->ctype_parameters['name'] );
$ext = array_pop( $name_parts );
if ( strtolower( $data['atype_extension'] ) == strtolower( $ext ) and $data['atype_post'] )
{
/* Create the file */
$masked_name = md5( uniqid( 'email' ) ) . "-{$part->ctype_parameters['name']}";
while ( is_file( $this->settings['upload_dir'] . "/{$masked_name}" ) )
{
$masked_name = md5( uniqid( 'email' ) . microtime() ) . "-{$part->ctype_parameters['name']}";
}
file_put_contents( $this->settings['upload_dir'] . "/{$masked_name}", $part->body );
/* Store attachment data */
$this->akey++;
$this->attachments[ $this->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'],
);
$content = "{ATTACHMENT:{$this->akey}}";
break;
}
}
}
$addedContent = FALSE;
if ( isset( $part->disposition ) and $part->disposition == 'inline' )
{
$contentId = trim( $part->headers['content-id'], '<>' );
if ( strpos( $this->message, $contentId ) !== FALSE )
{
switch ( $part->ctype_primary )
{
case 'image':
$this->message = preg_replace( "/<img.+?src=['\"]cid:{$contentId}['\"].*?>/", $content, $this->message );
$addedContent = TRUE;
break;
}
}
}
if ( !$addedContent )
{
$this->message .= $content;
}
return;
}
}
/**
* Decide if one part is better than another for parsing multipart/alternative
*
* @param stdClass Part 1
* @param stdClass Part 2
* @return bool TRUE if Part 2 is better than Part 1
*/
protected function _isBetter( $part1, $part2 )
{
/* Define our types */
$p1Primary = $part1->ctype_primary;
$p1Secondary = $part1->ctype_secondary;
$p2Primary = $part2->ctype_primary;
$p2Secondary = $part2->ctype_secondary;
/* If they're the same, return false */
if ( $p1Primary == $p2Primary and $p1Secondary == $p2Secondary )
{
return false;
}
/* Loop through preferences */
foreach ( $this->alternativePrefs as $primary => $secondary )
{
// Part 1 has this
if ( $p1Primary == $primary )
{
// Does part 2 have it to?
if ( $p2Primary == $primary )
{
// Yes - check secondaries
foreach ( $secondary as $s )
{
// Part 1 got it first? return false
if ( $p1Secondary == $s )
{
return false;
}
// Part 2 got it first - return true
elseif ( $p2Secondary == $s )
{
return true;
}
}
}
else
{
// No - then part 1 is better
return false;
}
}
// Part 2 has this but part 1 doesn't - part 2 is better
elseif ( $p2Primary == $primary )
{
return true;
}
}
/* Still here? Then we don't have details on this ctype - assume part 1 is better */
return false;
}
}
+9 -9
View File
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
+226 -51
View File
@@ -3,12 +3,12 @@
* @file composite.php Provides classes to manage the like system
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: This is NULLED!
* $Author: bfarber $
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* @since 11th October 2010
* $LastChangedDate: 2011-10-05 21:08:45 -0400 (Wed, 05 Oct 2011) $
* @version v3.2.3
* $Revision: 9586 $
* $LastChangedDate: 2012-06-18 11:11:25 -0400 (Mon, 18 Jun 2012) $
* @version v3.3.4
* $Revision: 10937 $
*
* <b>Example Usage:</b>
* @code
@@ -16,7 +16,6 @@
* $area = 'images';
* $like = classes_like::bootstrap( $app, $area );
* print $like->isLiked( $relId );
* $html = $like->render( 'summary', $relId );
* print $html;
*
@@ -309,8 +308,12 @@ class classes_like
}
/* Pointless comment! */
$_file = IPSLib::getAppDir( $app ) . '/extensions/like/' . $area . '.php';
$_class = 'like_' . $app . '_' . $area . '_composite';
if( $area != 'default' )
{
$_file = IPSLib::getAppDir( $app ) . '/extensions/like/' . $area . '.php';
$_class = 'like_' . $app . '_' . $area . '_composite';
}
$_key = md5( $app . $area );
/* Get from cache if already cached */
@@ -475,7 +478,7 @@ abstract class classes_like_composite
}
/* first check to ensure we've not already like'd this item */
if ( $this->isLiked($relId, $memberId) )
if ( $this->isLiked( $relId, $memberId, true ) )
{
/* if any one cares to check, then we're all good */
return false;
@@ -532,12 +535,15 @@ abstract class classes_like_composite
*
* @param integer $relId Relationship ID
* @param array $type Types of notifications to send (Possible: immediate, offline, daily, weekly)
* @param array $notificationOpts Notification options [Keys: notification_key, notification_url, email_template, email_subject, build_message_array, from (optional)]
* @param array $notificationOpts Notification options [Keys: notification_key, notification_url, email_template, email_subject, email_lang_file, email_lang_app, build_message_array, from (optional), ignore_data( type => ids )]
* @param array $sentToIds Pass a value by reference to get the ID numbers of members that were sent a notification
* @return @e boolean
* @see allowedFrequencies()
*/
public function sendNotifications( $relId, $type, $notificationOpts=array() )
public function sendNotifications( $relId, $type, $notificationOpts=array(), &$sentToIds=array() )
{
$sentToIds = array();
if ( empty( $relId ) )
{
trigger_error( "Data missing in " . __CLASS__ . '::' . __FUNCTION__, E_USER_WARNING );
@@ -554,10 +560,10 @@ abstract class classes_like_composite
}
$expire = IPS_UNIX_TIME_NOW - $_limit;
/* Fetch data by relID */
$data = $this->getDataByRelationshipId( $relId, false );
$data = $this->getDataByRelationshipId( $relId, false, (array) $notificationOpts['ignore_data'], $type );
/* Remove ourselves from notifications... */
if ( $this->memberData['member_id'] && isset($data[ $this->memberData['member_id'] ]) && $notificationOpts['includeOwner'] !== true )
{
@@ -597,6 +603,13 @@ abstract class classes_like_composite
{
continue;
}
/* Extra protection in case a ghost record is in the table for a member that doesn't exist
@link http://community.invisionpower.com/tracker/issue-36793-error-when-editing-some-marketplace-files */
if( !$row['like_member_id'] )
{
continue;
}
$buildMessage = array();
@@ -613,11 +626,13 @@ abstract class classes_like_composite
}
}
$sentToIds[] = $row['like_member_id'];
/* Add in unsubscribe link */
$key = $row['like_app'] . ';' . $row['like_area'] . ';' . $row['like_rel_id'] . ';' . $row['like_member_id'] . ';' . $row['member_id'] . ';' . $row['email'];
$buildMessage['UNSUBCRIBE_URL'] = $this->registry->output->buildSEOUrl( 'app=core&amp;module=global&amp;section=like&amp;do=unsubscribe&amp;key=' . IPSText::base64_encode_urlSafe( $key ), 'public', 'unsubscribe', 'likeunsubscribe' );
IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate( $notificationOpts['email_template'], $row['language'] ) );
IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate( $notificationOpts['email_template'], $row['language'], trim($notificationOpts['email_lang_file']), trim($notificationOpts['email_lang_app']) ) );
IPSText::getTextClass('email')->buildMessage( $buildMessage );
$notifyLibrary->setMember( $row );
@@ -625,7 +640,13 @@ abstract class classes_like_composite
$notifyLibrary->setNotificationKey( $notificationOpts['notification_key'] );
$notifyLibrary->setNotificationUrl( $notificationOpts['notification_url'] );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->getPlainTextContent() );
$notifyLibrary->setNotificationTitle( $notificationOpts['email_subject'] );
$notifyLibrary->setNotificationTitle( $notificationOpts['email_subject'] ? $notificationOpts['email_subject'] : IPSText::getTextClass('email')->subject );
if ( ! empty( $notificationOpts['email_only_subject'] ) && $notificationOpts['email_only_subject'] != IPSText::getTextClass('email')->subject )
{
$notifyLibrary->setEmailSubject( $notificationOpts['email_only_subject'], $row['language'], trim($notificationOpts['email_lang_file']), trim($notificationOpts['email_lang_app']) );
}
try
{
$notifyLibrary->sendNotification();
@@ -639,28 +660,48 @@ abstract class classes_like_composite
$this->DB->update( 'core_like', array( 'like_notify_sent' => IPS_UNIX_TIME_NOW ), "like_id='" . classes_like_registry::getKey( $row['like_rel_id'], $row['like_member_id'] ) . "'" );
}
return true;
return ( is_array( $sentToIds ) ) ? array_unique( $sentToIds ) : true;
}
/**
* Send digest notifications to anyone subscribed to item
*
* @param string $type Types of notifications to send (Possible: daily, weekly)
* @param integer $sendMax Null (use ipsRegistry::$setting or send INT only)
* @return @e boolean
* @see allowedFrequencies()
*/
public function sendDigestNotifications( $type )
public function sendDigestNotifications( $type, $sendMax=null )
{
/* Fetch data */
$blackhole = mktime( 0, 0 );
$blackhole = time(); // mktime( 0, 0 ); - http://community.invisionpower.com/tracker/issue-35320-daily-digests-every-2-days
$time = ( $type == 'daily' ) ? $blackhole - ( 86400 ) : $blackhole - ( 86400 * 7 );
$data = $this->getDataByAreaAndLastSentOlderThanDate( $time, array( 'daily', 'weekly' ) );
$data = $this->getDataByAreaAndLastSentOlderThanDate( $time, array( $type ), false, $sendMax );
if ( ! count( $data ) )
{
return false;
}
/* Check for outdated notifications and update them as required */
$oldestPossDate = 0;
if ( $type == 'daily' )
{
/* Grab 4 days to account for timezone differences */
$oldestPossDate = $blackhole - ( 86400 * 4 );
}
else
{
/* Grab 10 days to ensure we don't update rows ready to be sent */
$oldestPossDate = $blackhole - ( 86400 * 10 );
}
if ( $oldestPossDate )
{
$this->DB->update( 'core_like', array( 'like_notify_sent' => IPS_UNIX_TIME_NOW ), 'like_notify_sent < ' . $oldestPossDate );
}
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
@@ -669,24 +710,23 @@ abstract class classes_like_composite
{
foreach( $_rows as $row )
{
if ( ! $row['like_notify_freq'] OR ! in_array( $row['like_notify_freq'], array( 'daily', 'weekly' ) ) )
if ( ! $row['like_notify_freq'] OR $row['like_notify_freq'] != $type )
{
continue;
}
/* Make sure we don't send huge digests if this is their first email since subscribing */
$row['like_notify_sent'] = $row['like_notify_sent'] ? $row['like_notify_sent'] : $row['like_added'];
if( $row['like_notify_sent'] < ( time() - 604800 ) )
{
$row['like_notify_sent'] = time() - 604800;
}
/* Want to fetch the data from the plug in files? */
$notificationOpts = $this->buildNotificationData( $row, $type );
if ( ! is_array( $notificationOpts ) OR ! count( $notificationOpts ) )
{
/* This will get hit if topic hasn't had a post since notification was last sent - to prevent the same row from getting picked up each time this runs
we need to update the last sent timestamp for the like */
$this->DB->update( 'core_like', array( 'like_notify_sent' => IPS_UNIX_TIME_NOW ), 'like_id=\'' . classes_like_registry::getKey( $row['like_rel_id'], $row['like_member_id'] ) . '\'' );
continue;
}
@@ -705,7 +745,7 @@ abstract class classes_like_composite
}
}
IPSText::getTextClass('email')->getTemplate( $notificationOpts['email_template'], $row['language'] );
IPSText::getTextClass('email')->getTemplate( $notificationOpts['email_template'], $row['language'], trim($notificationOpts['email_lang_file']), trim($notificationOpts['email_lang_app']) );
IPSText::getTextClass('email')->buildMessage( $buildMessage );
$notifyLibrary->setMember( $row );
@@ -713,7 +753,8 @@ abstract class classes_like_composite
$notifyLibrary->setNotificationKey( $notificationOpts['notification_key'] );
$notifyLibrary->setNotificationUrl( $notificationOpts['notification_url'] );
$notifyLibrary->setNotificationText( IPSText::getTextClass('email')->message );
$notifyLibrary->setNotificationTitle( $notificationOpts['email_subject'] );
$notifyLibrary->setNotificationTitle( $notificationOpts['email_subject'] ? $notificationOpts['email_subject'] : IPSText::getTextClass('email')->subject );
try
{
$notifyLibrary->sendNotification();
@@ -828,6 +869,72 @@ abstract class classes_like_composite
return true;
}
/**
* Updates a member's ID in the like rows
*
* @param integer Old Id
* @param integer New Id
*/
public function updateMemberId( $oldId, $newId )
{
$_likes = array();
/* We might be merging */
$this->DB->build( array( 'select' => 'like_lookup_id', 'from' => 'core_like', 'where' => "like_member_id=" . $newId ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$_likes[] = $r['like_lookup_id'];
}
/* not done */
if ( count( $_likes ) )
{
$this->DB->update( 'core_like' , array( 'like_member_id' => $newId ), "like_member_id=" . $oldId . " AND like_lookup_id NOT IN('" . implode( "','", array_map( 'addslashes', $_likes ) ) . "')" );
$this->DB->delete( 'core_like_cache' , "like_cache_id IN('" . implode( "','", array_map( 'addslashes', $_likes ) ) . "')" );
}
else
{
$this->DB->update( 'core_like' , array( 'like_member_id' => $newId ), "like_member_id=" . $oldId );
}
/* Now remove duplicates */
$dupes = array();
$this->DB->build( array( 'select' => 'like_id, count(*) as cnt',
'from' => 'core_like',
'where' => 'like_member_id=' . $newId,
'group' => 'like_app, like_area, like_member_id, like_rel_id',
'order' => 'cnt desc' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
if ( $row['cnt'] < 2 )
{
break;
}
else
{
$dupes[] = $row['like_id'];
}
}
/* Do it? */
if ( count( $dupes ) )
{
$this->DB->delete( 'core_like' , "like_cache IN('" . implode( "','", array_map( 'addslashes', $dupes ) ) . "')" );
}
/* Now re-update so that hashes are correct */
$update = "like_id=MD5( CONCAT( like_app, ';', like_area, ';', like_rel_id, ';', like_member_id ) ), " .
"like_lookup_area=MD5( CONCAT( like_app, ';', like_area, ';', like_member_id ) )";
$where = "like_member_id=" . $newId;
$this->DB->update( 'core_like', $update, $where, false, true );
}
/**
* Return number of people who 'like' the item
*
@@ -849,6 +956,7 @@ abstract class classes_like_composite
* @param array $opts Options
* @param integer $memberId Member ID
* @return @e string Formatted HTML
* @todo If $cache['count'] is 0, we can probably skip the getDataByMemberIdAndRelationshipId() call as it will be empty
*/
public function render( $view, $relId, $opts=array(), $memberId=null )
{
@@ -861,7 +969,7 @@ abstract class classes_like_composite
$max = 0;
/* Fetch data for us? */
if ( $this->memberData['member_id'] )
if ( $this->memberData['member_id'] && ( $cache['count'] + $cache['count_anon'] ) > 0 )
{
/* We can't use isLiked or it runs twice the query and adding a cache to the function doesn't work either */
$_me = $this->getDataByMemberIdAndRelationshipId( $relId, $this->memberData['member_id'] );
@@ -1006,12 +1114,13 @@ abstract class classes_like_composite
*
* @param mixed $relId Relationship IDs (int|array)
* @param integer $memberId Member ID
* @param boolean $checkNotVisibleToo return a match even if not visible to the user
* @return @e boolean
*/
public function isLiked( $relId, $memberId )
public function isLiked( $relId, $memberId, $checkNotVisibleToo=false )
{
/* Grab the data */
return ( $this->getDataByMemberIdAndRelationshipId( $relId, $memberId ) === null ) ? false : true;
return ( $this->getDataByMemberIdAndRelationshipId( $relId, $memberId, $checkNotVisibleToo ) === null ) ? false : true;
}
/**
@@ -1019,9 +1128,10 @@ abstract class classes_like_composite
*
* @param mixed $relId Relationship IDs (int|array)
* @param integer $memberId Member ID
* @param boolean $checkNotVisibleToo return a match even if not visible to the user
* @return @e mixed Array of likes data OR null
*/
public function getDataByMemberIdAndRelationshipId( $relId, $memberId )
public function getDataByMemberIdAndRelationshipId( $relId, $memberId, $checkNotVisibleToo=false )
{
$where = '';
$data = null;
@@ -1049,7 +1159,10 @@ abstract class classes_like_composite
}
$where .= ' AND like_visible=1';
if ( $checkNotVisibleToo === false )
{
$where .= ' AND like_visible=1';
}
$this->DB->build( array( 'select' => '*',
'from' => 'core_like',
@@ -1103,24 +1216,34 @@ abstract class classes_like_composite
*
* @param integer $relId Relationship ID
* @param boolean $skipAnon Skip anonymous rows flag
* @param array
* @param array Type of follow (immediate, none, offline, daily, etc)
* @return @e mixed Array of likes data OR null
*/
public function getDataByRelationshipId( $relId, $skipAnon=true )
public function getDataByRelationshipId( $relId, $skipAnon=true, $ignoreData=array(), $followType=array() )
{
/* Init */
$mids = array();
$members = array();
$rows = array();
$_isAnon = $skipAnon ? 'AND like_is_anon=0' : '';
$_whereB = $this->memberData['member_id'] ? " OR like_id='" . classes_like_registry::getKey( $relId, $this->memberData['member_id'] ) . "'" : '';
$mids = array();
$members = array();
$rows = array();
$followType = is_array( $followType ) ? $followType : array( $followType );
$_isAnon = $skipAnon ? 'AND like_is_anon=0' : '';
$_whereB = $this->memberData['member_id'] ? " OR like_id='" . classes_like_registry::getKey( $relId, $this->memberData['member_id'] ) . "'" : '';
/* Fetch data */
/* Add in follow type */
if ( count( $followType ) )
{
$_whereB .= " AND like_notify_freq IN ('" . implode( "','", $followType ) ."')";
}
/* Fetch data */
$this->DB->build( array( 'select' => '*',
'from' => 'core_like',
'where' => "((like_lookup_id='" . classes_like_registry::getKey( $relId ) . "' {$_isAnon}) {$_whereB}) AND like_visible=1",
'order' => 'like_added DESC',
'limit' => array( 0, 250 ) ) );
'limit' => array( 0, 500 ) ) );
$o = $this->DB->execute();
while( $row = $this->DB->fetch( $o ) )
@@ -1141,6 +1264,27 @@ abstract class classes_like_composite
}
}
/* Are we giving this bloke a good ignoring? */
if ( !empty( $ignoreData ) )
{
$ignoreWhere = array();
foreach ( $ignoreData as $type => $ids )
{
$ignoreWhere[] = "( {$type}=1 AND " . $this->DB->buildWherePermission( $ids, 'ignore_ignore_id', FALSE ) . ')';
}
$this->DB->build( array( 'select' => '*', 'from' => 'ignored_users', 'where' => implode( ' OR ', $ignoreWhere ) ) );
$this->DB->execute();
while ( $row = $this->DB->fetch() )
{
if ( isset( $data[ $row['ignore_owner_id'] ] ) )
{
unset( $data[ $row['ignore_owner_id'] ] );
}
}
}
return is_array($data) ? $data : null;
}
@@ -1150,10 +1294,11 @@ abstract class classes_like_composite
* @param integer $date Unix timestamp
* @param array $types Array of notification types (optional)
* @param array $parseMembers Parse extra data for each member and build display photo (false is default)
* @param integer $sendMax Null (use ipsRegistry::$setting or send INT only)
* @return @e mixed Array of likes data OR null
* @see allowedFrequencies()
*/
public function getDataByAreaAndLastSentOlderThanDate( $date, $types=array(), $parseMembers=false )
public function getDataByAreaAndLastSentOlderThanDate( $date, $types=array(), $parseMembers=false, $sendMax=null )
{
/* Init */
$mids = array();
@@ -1161,6 +1306,7 @@ abstract class classes_like_composite
$rows = array();
$joins = array();
$where = ( is_array( $types ) ) ? ' AND l.like_notify_freq IN (\'' . implode( "','", $types ) . '\')' : '';
$sendMax = ( $sendMax !== null ) ? $sendMax : ipsRegistry::$settings['like_notifications_limit'];
/* figure out joins */
$joins[] = array( 'select' => 'm.*',
@@ -1177,13 +1323,32 @@ abstract class classes_like_composite
$joins[] = $join;
}
}
/* Prevent it going back EONS AND EONS */
$oldestPossDate = 0;
if ( in_array( 'weekly', $types ) )
{
/* Grab 8 days to account for timezone differences */
$oldestPossDate = $date - ( 86400 * 8 );
}
else
{
/* Grab 2 days to account for timezone differences */
$oldestPossDate = $date - ( 86400 * 2 );
}
if ( $oldestPossDate )
{
$where .= ' AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) > ' . intval( $oldestPossDate );
}
/* Fetch data */
$this->DB->build( array( 'select' => 'l.*',
'from' => array( 'core_like' => 'l' ),
'where' => 'l.like_notify_do=1 AND l.like_app=\'' . classes_like_registry::getApp() . '\' AND l.like_area=\'' . classes_like_registry::getArea() . '\' AND l.like_visible=1 AND l.like_notify_sent < ' . intval( $date ) . $where,
'where' => 'l.like_notify_do=1 AND l.like_app=\'' . classes_like_registry::getApp() . '\' AND l.like_area=\'' . classes_like_registry::getArea() . '\' AND l.like_visible=1 AND ( CASE WHEN l.like_notify_sent > 0 THEN l.like_notify_sent ELSE l.like_added END ) < ' . intval( $date ) . $where,
'order' => 'l.like_notify_sent ASC',
'limit' => array( 0, ipsRegistry::$settings['like_notifications_limit'] ),
'limit' => array( 0, $sendMax ),
'add_join' => $joins ) );
$o = $this->DB->execute();
@@ -1193,9 +1358,19 @@ abstract class classes_like_composite
$row['like_member_id'] = intval($row['like_member_id']);
$mids[ $row['like_member_id'] ] = $row['like_member_id'];
/* Need to apply secondary groups and grab g_perm_id if $parseMembers is false (default)
@link http://community.invisionpower.com/tracker/issue-34691-digest-notifications-not-going-out/ */
$row['mgroup_others'] = ($row['mgroup_others'] != '') ? IPSText::cleanPermString($row['mgroup_others']) : '';
$row = array_merge( $row, $this->caches['group_cache'][ $row['member_group_id'] ] );
$row = $this->registry->member()->setUpSecondaryGroups( $row );
if( $row['topic_last_post'] )
{
$row['last_post'] = $row['topic_last_post'];
}
/* @link http://community.invisionpower.com/tracker/issue-32204-dailyweekly-notifications */
$data[ $row['like_member_id'] ][ $row['like_id'] ] = $row;
}
/* Just the one? */
@@ -1605,7 +1780,7 @@ class classes_like_cache
'where' => 'like_cache_id=\'' . classes_like_registry::getKey( $relId ) . '\'' ) );
if ( !is_array($cache) OR $cache['like_cache_expire'] <= IPS_UNIX_TIME_NOW )
{
{
/* We don't have a valid cache, so create one and return the data */
$cache = $this->create( $relId, $memberId );
}
+9 -9
View File
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
+314 -316
View File
@@ -1,317 +1,315 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Generic Mapping Class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-03-10 16:00:38 -0500 (Thu, 10 Mar 2011) $
*
* @example
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8021 $
*/
/**
* Factory class
*
* @author matt
*
*/
class classes_mapping
{
/**
* App object
* @var object
*/
static protected $_app;
/**
* Construct
*/
static public function bootstrap( $engine )
{
if ( ! $engine )
{
trigger_error( "No engine specified for class_mapping", E_USER_WARNING );
}
/* Pointless comment! */
$_file = IPS_ROOT_PATH . 'sources/classes/mapping/engines/' . $engine . '.php';
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, 'classes_mapping_' . $engine );
if ( class_exists( $classToLoad ) )
{
self::$_app = new $classToLoad();
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
return self::$_app;
}
}
/**
* Composite class
*/
abstract class classes_mapping_composite
{
/**
*
* Location services available flag
* @return boolean
*/
public function enabled()
{
return ( $this->fetchApiKey() ) ? true : false;
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return false;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function reverseGeoCodeLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* First check the DB, this is bound to be cheaper than sockets and Yahoo APIs
* and it's likely that in an album of images one has already has set the geo location */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'core_geolocation_cache',
'where' => 'geocache_key=\'' . $this->getDbKey( $lat, $lon ) . '\'',
'limit' => array( 0, 1 ) ) );
if ( ! empty( $test['geocache_country'] ) )
{
return $test;
}
/* Still here? Oh well, lets do it. */
$data = $this->liveReverseLookUp( $lat, $lon );
if ( ! is_array( $data ) )
{
return null;
}
$formatted = $this->formatReverseLookUp( $data );
/* Save to db */
if ( $formatted !== false && ! empty( $formatted['country'] ) )
{
$save = array( 'geocache_key' => $this->getDbKey( $lat, $lon ),
'geocache_lat' => $lat,
'geocache_lon' => $lon,
'geocache_raw' => serialize( $data ),
'geocache_country' => $formatted['country'],
'geocache_district' => $formatted['district'],
'geocache_district2' => $formatted['district2'],
'geocache_locality' => $formatted['locality'],
'geocache_type' => $formatted['type'],
'geocache_engine' => $formatted['engine'],
'geocache_added' => time(),
'geocache_short' => $formatted['short'] );
$this->DB->replace( 'core_geolocation_cache', $save, array( 'geocache_key' ) );
return $save;
}
else
{
return false;
}
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
return array( false, false );
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
return $array;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return false;
}
/**
* Make a key for the DB
* @param string $lat
* @param string $lon
* @return string
*/
protected function getDbKey( $lat, $lon )
{
return md5( trim($lat) . ',' . trim($lon) );
}
/**
* Attempt to get images from the cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _getImagesFromCache( $lat, $lon, $size )
{
$file_0 = md5( $lat . ',' . $lon . ',' . $size ) . '_0.png';
$file_1 = md5( $lat . ',' . $lon . ',' . $size ) . '_1.png';
if ( is_file( $this->_getCachePath() . '/' . $file_0 ) && is_file( $this->_getCachePath() . '/' . $file_1 ) )
{
return array( $this->_getCacheUrl() . '/' . $file_0, $this->_getCacheUrl() . '/' . $file_1 );
}
else
{
return false;
}
}
/**
* Write images to cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _setImageCache( $lat, $lon, $size, $key, $data )
{
if ( ! is_dir( $this->settings['upload_dir'] . '/maps' ) )
{
@mkdir( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
@chmod( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
}
$filename = md5( $lat . ',' . $lon . ',' . $size ) . '_' . $key;
/* Extension less */
if ( @file_put_contents( $this->_getCachePath() . '/' . $filename, $data ) )
{
$data = @getimagesize( $this->_getCachePath() . '/' . $filename );
if ( ! is_array( $data ) OR ! count( $data ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
else
{
if ( $data['mime'] == 'image/png' )
{
/* Add ext */
if ( ! @rename( $this->_getCachePath() . '/' . $filename, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else
{
if ( $data['mime'] == 'image/jpg' )
{
$gd = @imagecreatefromjpeg( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else if ( $data['mime'] == 'image/gif' )
{
$gd = @imagecreatefromgif( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
}
}
}
else
{
return false;
}
return true;
}
/**
* Returns cache path
* @return string
*/
protected function _getCachePath()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_dir'] . '/maps' : $this->settings['upload_dir'];
}
/**
* Returns cache path
* @return string
*/
protected function _getCacheUrl()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_url'] . '/maps' : $this->settings['upload_url'];
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Generic Mapping Class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
/**
* Factory class
*
* @author matt
*
*/
class classes_mapping
{
/**
* App object
* @var object
*/
static protected $_app;
/**
* Construct
*/
static public function bootstrap( $engine )
{
if ( ! $engine )
{
trigger_error( "No engine specified for class_mapping", E_USER_WARNING );
}
/* Pointless comment! */
$_file = IPS_ROOT_PATH . 'sources/classes/mapping/engines/' . $engine . '.php';
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, 'classes_mapping_' . $engine );
if ( class_exists( $classToLoad ) )
{
self::$_app = new $classToLoad();
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
return self::$_app;
}
}
/**
* Composite class
*/
abstract class classes_mapping_composite
{
/**
*
* Location services available flag
* @return boolean
*/
public function enabled()
{
return ( $this->fetchApiKey() ) ? true : false;
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return false;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function reverseGeoCodeLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* First check the DB, this is bound to be cheaper than sockets and Yahoo APIs
* and it's likely that in an album of images one has already has set the geo location */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'core_geolocation_cache',
'where' => 'geocache_key=\'' . $this->getDbKey( $lat, $lon ) . '\'',
'limit' => array( 0, 1 ) ) );
if ( ! empty( $test['geocache_country'] ) )
{
return $test;
}
/* Still here? Oh well, lets do it. */
$data = $this->liveReverseLookUp( $lat, $lon );
if ( ! is_array( $data ) )
{
return null;
}
$formatted = $this->formatReverseLookUp( $data );
/* Save to db */
if ( $formatted !== false && ! empty( $formatted['country'] ) )
{
$save = array( 'geocache_key' => $this->getDbKey( $lat, $lon ),
'geocache_lat' => $lat,
'geocache_lon' => $lon,
'geocache_raw' => serialize( $data ),
'geocache_country' => $formatted['country'],
'geocache_district' => $formatted['district'],
'geocache_district2' => $formatted['district2'],
'geocache_locality' => $formatted['locality'],
'geocache_type' => $formatted['type'],
'geocache_engine' => $formatted['engine'],
'geocache_added' => time(),
'geocache_short' => $formatted['short'] );
$this->DB->replace( 'core_geolocation_cache', $save, array( 'geocache_key' ) );
return $save;
}
else
{
return false;
}
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
return array( false, false );
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
return $array;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return false;
}
/**
* Make a key for the DB
* @param string $lat
* @param string $lon
* @return string
*/
protected function getDbKey( $lat, $lon )
{
return md5( trim($lat) . ',' . trim($lon) );
}
/**
* Attempt to get images from the cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _getImagesFromCache( $lat, $lon, $size )
{
$file_0 = md5( $lat . ',' . $lon . ',' . $size ) . '_0.png';
$file_1 = md5( $lat . ',' . $lon . ',' . $size ) . '_1.png';
if ( is_file( $this->_getCachePath() . '/' . $file_0 ) && is_file( $this->_getCachePath() . '/' . $file_1 ) )
{
return array( $this->_getCacheUrl() . '/' . $file_0, $this->_getCacheUrl() . '/' . $file_1 );
}
else
{
return false;
}
}
/**
* Write images to cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _setImageCache( $lat, $lon, $size, $key, $data )
{
if ( ! is_dir( $this->settings['upload_dir'] . '/maps' ) )
{
@mkdir( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
@chmod( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
}
$filename = md5( $lat . ',' . $lon . ',' . $size ) . '_' . $key;
/* Extension less */
if ( @file_put_contents( $this->_getCachePath() . '/' . $filename, $data ) )
{
$data = @getimagesize( $this->_getCachePath() . '/' . $filename );
if ( ! is_array( $data ) OR ! count( $data ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
else
{
if ( $data['mime'] == 'image/png' )
{
/* Add ext */
if ( ! @rename( $this->_getCachePath() . '/' . $filename, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else
{
if ( $data['mime'] == 'image/jpg' )
{
$gd = @imagecreatefromjpeg( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else if ( $data['mime'] == 'image/gif' )
{
$gd = @imagecreatefromgif( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
}
}
}
else
{
return false;
}
return true;
}
/**
* Returns cache path
* @return string
*/
protected function _getCachePath()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_dir'] . '/maps' : $this->settings['upload_dir'];
}
/**
* Returns cache path
* @return string
*/
protected function _getCacheUrl()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_url'] . '/maps' : $this->settings['upload_url'];
}
}
@@ -1,252 +1,250 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
*
* @example
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*/
class classes_mapping_bing extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return defined( 'BING_API_KEY' ) ? BING_API_KEY : false;
}
//$result = $file->getFileContents( "http://where.yahooapis.com/geocode?appid=" . $this->getYahooAppId() . "&location=" . $lat . "," . $lon . "&flags=J&gflags=R&locale=" . YAHOO_LOCALE );
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://dev.virtualearth.net/REST/v1/Locations/" . $lat . "," . $lon . "?&key=" . BING_API_KEY );
if ( strstr( $json, ':{"' ) )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['statusCode'] ) AND $array['statusCode'] == 200 )
{
return $array['resourceSets'][0]['resources'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'bing' );
if ( is_array( $array ) )
{
$return['country'] = $array['address']['countryRegion'];
$return['district'] = $array['address']['adminDistrict'];
$return['district2'] = $array['address']['adminDistrict2'];
$return['locality'] = $array['address']['locality'];
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://www.bing.com/maps/?v=2&encType=1&where1=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$_size = str_replace( 'x', ',', $size );
$latlon = $lat . ',' . $lon;
$base = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/%s/%s/?mapSize=%s&pp=%s;9;A&key=" . $this->fetchApiKey();
$image0 = sprintf( $base, $latlon, 7, $_size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $_size, $latlon );
/* Try from cache */
$images = $this->_getImagesFromCache( $lat, $lon, $size );
if ( $images === false )
{
/* Fetch live */
if ( $_data_0 = @file_get_contents( $image0 ) )
{
$_data_1 = @file_get_contents( $image1 );
/* Attempt to write cache */
if ( $this->_setImageCache( $lat, $lon, $size, 0, $_data_0 ) !== false )
{
$this->_setImageCache( $lat, $lon, $size, 1, $_data_1 );
}
}
}
else
{
return array( $images[0], $images[1] );
}
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
class classes_mapping_bing extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return defined( 'BING_API_KEY' ) ? BING_API_KEY : false;
}
//$result = $file->getFileContents( "http://where.yahooapis.com/geocode?appid=" . $this->getYahooAppId() . "&location=" . $lat . "," . $lon . "&flags=J&gflags=R&locale=" . YAHOO_LOCALE );
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://dev.virtualearth.net/REST/v1/Locations/" . $lat . "," . $lon . "?&key=" . BING_API_KEY );
if ( strstr( $json, ':{"' ) )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['statusCode'] ) AND $array['statusCode'] == 200 )
{
return $array['resourceSets'][0]['resources'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'bing' );
if ( is_array( $array ) )
{
$return['country'] = $array['address']['countryRegion'];
$return['district'] = $array['address']['adminDistrict'];
$return['district2'] = $array['address']['adminDistrict2'];
$return['locality'] = $array['address']['locality'];
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://www.bing.com/maps/?v=2&encType=1&where1=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$_size = str_replace( 'x', ',', $size );
$latlon = $lat . ',' . $lon;
$base = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/%s/%s/?mapSize=%s&pp=%s;9;A&key=" . $this->fetchApiKey();
$image0 = sprintf( $base, $latlon, 7, $_size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $_size, $latlon );
/* Try from cache */
$images = $this->_getImagesFromCache( $lat, $lon, $size );
if ( $images === false )
{
/* Fetch live */
if ( $_data_0 = @file_get_contents( $image0 ) )
{
$_data_1 = @file_get_contents( $image1 );
/* Attempt to write cache */
if ( $this->_setImageCache( $lat, $lon, $size, 0, $_data_0 ) !== false )
{
$this->_setImageCache( $lat, $lon, $size, 1, $_data_1 );
}
}
}
else
{
return array( $images[0], $images[1] );
}
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -1,244 +1,242 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
*
* @example
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*/
class classes_mapping_google extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return true;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . ',' . $lon . '&sensor=false' );
if ( $json )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['status'] ) AND strtolower( $array['status'] ) == 'ok' )
{
return $array['results'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'google' );
if ( is_array( $array ) )
{
foreach( $array['address_components'] as $idx => $data )
{
$key = $data['types'][0];
switch( $key )
{
case 'country':
$return['country'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_1':
$return['district'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_2':
$return['district2'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'sublocality':
$return['locality'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
}
}
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://maps.google.com/?zoom=11&q=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$latlon = $lat . ',' . $lon;
$base = "http://maps.google.com/maps/api/staticmap?center=%s&zoom=%s&size=%s&maptype=roadmap&markers=color:red|label:A|%s&sensor=false";
$image0 = sprintf( $base, $latlon, 7, $size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $size, $latlon );
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
class classes_mapping_google extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return true;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . ',' . $lon . '&sensor=false' );
if ( $json )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['status'] ) AND strtolower( $array['status'] ) == 'ok' )
{
return $array['results'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'google' );
if ( is_array( $array ) )
{
foreach( $array['address_components'] as $idx => $data )
{
$key = $data['types'][0];
switch( $key )
{
case 'country':
$return['country'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_1':
$return['district'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_2':
$return['district2'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'sublocality':
$return['locality'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
}
}
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://maps.google.com/?zoom=11&q=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$latlon = $lat . ',' . $lon;
$base = "http://maps.google.com/maps/api/staticmap?center=%s&zoom=%s&size=%s&maptype=roadmap&markers=color:red|label:A|%s&sensor=false";
$image0 = sprintf( $base, $latlon, 7, $size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $size, $latlon );
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,525 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Mobile iOS App image class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10721 $
*/
/**
* Manages mobile app images for the ACP
*
* @author matt
*
*/
class classes_mobile_iosImages
{
/**
* Image names
* @var string
*/
protected $_fileNames = array( 'ActionBarBackground',
'actionButton',
'actionButtonActive',
'backButton',
'backButtonActive',
'menuButton',
'menuButtonActive',
'NavBarBackground',
'readIcon',
'unreadIcon' );
/**
* Retina suffix
* @var string
*/
protected $_retinaSuffix = '@2x';
/**
* Mobile app folder
*/
protected $_imageDir = '';
protected $_imageUrl = '';
protected $_defaultDir = '';
protected $_defaultImageUrl = '';
protected $_cache = array( 'default' => array(), 'current' => array() );
/**
* Style last updated timestampe
*/
protected $_styleLastUpdated = 0;
/**
* Constructor
*/
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
/* Set up */
$this->setImageDir();
$this->setImageUrl();
$this->setStyleLastUpdated();
$this->setDefaultImageDir();
$this->setDefaultImageUrl();
}
/**
* Sets style last updated
* @param string (Optional dir)
*/
public function setStyleLastUpdated( $time=0 )
{
$this->_styleLastUpdated = ( $time ) ? $time : intval( ipsRegistry::$settings['style_last_updated'] );
/* Do we need to update the setting? */
if ( $time && ( $time > ipsRegistry::$settings['style_last_updated'] ) )
{
/* Rebuild DB */
$this->_refreshDatabase();
/* Update setting */
IPSLib::updateSettings( array( 'style_last_updated' => $time + 1 ) );
/* Flsuh cache */
$this->_flushCache();
}
}
/**
* Get image dir
* @return string
*/
public function getStyleLastUpdated()
{
return $this->_styleLastUpdated;
}
/**
* Sets the default image url
* @param string (Optional dir)
*/
public function setDefaultImageUrl( $url='' )
{
$this->_defaultImageUrl = ( $url ) ? $url : ipsRegistry::$settings['public_dir'] . 'style_extra/default_mobile_app/';
}
/**
* Sets the default image dir
* @param string (Optional dir)
*/
public function setDefaultImageDir( $dir='' )
{
$this->_defaultDir = ( $dir ) ? $dir : DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_extra/default_mobile_app/';
}
/**
* Sets the image dir
* @param string (Optional dir)
*/
public function setImageDir( $dir='' )
{
$this->_imageDir = ( $dir ) ? $dir : DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_images/mobile_app/';
}
/**
* Sets the image url
* @param string (Optional dir)
*/
public function setImageUrl( $url='' )
{
$this->_imageUrl = ( $url ) ? $url : ipsRegistry::$settings['public_dir'] . 'style_images/mobile_app/';
}
/**
* Get default image dir
* @return string
*/
public function getDefaultImageDir()
{
return $this->_defaultDir;
}
/**
* Get image dir
* @return string
*/
public function getImageDir()
{
return $this->_imageDir;
}
/**
* Get default image url
* @return string
*/
public function getDefaultImageUrl()
{
return $this->_defaultImageUrl;
}
/**
* Get image url
* @return string
*/
public function getImageUrl()
{
return $this->_imageUrl;
}
/**
* Get retina suffix
* @return string
*/
public function getRetinaSuffix()
{
return $this->_retinaSuffix;
}
/**
* Get default image dir contents
* @return array Of data (filename, mtime, size)
*/
public function getDefaultImageDirContents()
{
$images = array();
$cache = $this->_getCache( 'default' );
if ( $cache !== false )
{
return $cache;
}
/* Grab data */
try
{
foreach( new DirectoryIterator( $this->getDefaultImageDir() ) as $file )
{
if ( ! $file->isDot() AND ! $file->isDir() )
{
$_name = $file->getFileName();
if ( substr( $_name, 0, 1 ) != '.' )
{
if ( substr( $_name, -4 ) == '.png' )
{
try
{
$data = getimagesize( $this->getDefaultImageDir() . '/' . $_name );
}
catch( Exception $e ) { }
$images[] = array( 'filename' => $_name,
'imgsrc' => $this->getImageUrl() . $file,
'dimensions' => array( $data[0], $data[1] ),
'mtime' => $file->getMTime(),
'size' => $file->getSize(),
'writeable' => $file->isWritable() );
}
}
}
}
} catch ( Exception $e ) {}
/* Add to cache */
$this->_addCache( 'default', $images );
return $images;
}
/**
* Get current image dir contents
* @return array Of data (filename, mtime, size)
*/
public function getImageDirContents()
{
$images = array();
$cache = $this->_getCache( 'current' );
if ( $cache !== false )
{
return $cache;
}
try
{
foreach( new DirectoryIterator( $this->getImageDir() ) as $file )
{
if ( ! $file->isDot() AND ! $file->isDir() )
{
$_name = $file->getFileName();
if ( substr( $_name, 0, 1 ) != '.' )
{
if ( substr( $_name, -4 ) == '.png' )
{
try
{
$data = getimagesize( $this->getImageDir() . '/' . $_name );
}
catch( Exception $e ) { }
$images[] = array( 'filename' => $_name,
'imgsrc' => $this->getImageUrl() . $file,
'dimensions' => array( $data[0], $data[1] ),
'mtime' => $file->getMTime(),
'size' => $file->getSize(),
'writeable' => $file->isWritable() );
}
}
}
}
} catch ( Exception $e ) { }
/* Add to cache */
$this->_addCache( 'current', $images );
return $images;
}
/**
* Get filenames
* @return array
*/
public function getFileNames()
{
return $this->_fileNames;
}
/**
* Checks directories
* @return array Error codes
*/
public function checkDirectories()
{
$errors = array();
/* Exists */
if ( ! is_dir( $this->getImageDir() ) )
{
$errors[] = array( 'key' => 'doesnt_exist',
'extra' => $this->getImageDir() );
}
if ( ! is_dir( $this->getDefaultImageDir() ) )
{
$errors[] = array( 'key' => 'doesnt_exist',
'extra' => $this->getDefaultImageDir() );
}
/* is writeable */
if ( ! is_writeable( $this->getImageDir() ) )
{
$errors[] = array( 'key' => 'cannot_write',
'extra' => $this->getImageDir() );
}
return ( count( $errors ) ) ? $errors : false;
}
/**
* Check images
* @return array Error codes
*/
public function checkImages()
{
$default = $this->getDefaultImageDirContents();
$images = $this->getImageDirContents();
$fileNames = $this->getFileNames();
$workingImages = array();
$errors = array( 'missing' => false, 'dimensions' => false, 'writeable' => false );
foreach( $images as $i )
{
$workingImages[ $i['filename'] ] = true;
}
/* Lets see if any are missing */
foreach( $fileNames as $name )
{
$image = $this->_getFileFromArray( $name . '.png', $images );
if ( $image === false )
{
$errors['missing'][] = $name . '.png';
}
}
/* Are they the correct size? */
foreach( $default as $def )
{
$image = $this->_getFileFromArray( $def['filename'], $images );
if ( $image['dimensions'] && $def['dimensions'] )
{
if ( ( $image['dimensions'][0] != $def['dimensions'][0] ) || ( $image['dimensions'][1] != $def['dimensions'][1] ) )
{
$errors['dimensions'][] = $def['filename'];
}
}
if ( ! is_writeable( $this->getImageDir() . $image['filename'] ) )
{
$errors['writeable'][] = $image['filename'];
}
}
return ( count( $errors ) ) ? $errors : false;
}
/**
* Return an XML archive
* @return string
*/
public function getXmlArchive()
{
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
$xmlArchive = new classXMLArchive();
$xmlArchive->setStripPath( $this->getImageDir() );
$xmlArchive->add( $this->getImageDir() );
$xml = $xmlArchive->getArchiveContents();
return $xml;
}
/**
* Imports a set XMLArchive
*
* @access public
* @param string XMLArchive content to import
* @return mixed Number of items added, or bool
*/
public function importXmlArchive( $content )
{
/* Correct file type ? */
if ( ! strstr( $content, "<xmlarchive" ) )
{
return false;
}
/* Get XML class */
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
$xmlArchive = new classXMLArchive();
$xmlArchive->readXML( $content );
/* Got stuff? */
if ( ! $xmlArchive->countFileArray() )
{
return false;
}
/* Write it */
if ( $xmlArchive->write( $content, $this->getImageDir() ) === FALSE )
{
return false;
}
/* Check images */
$errors = $this->checkImages();
if ( $errors['missing'] !== false OR $errors['dimensions'] !== false OR $errors['writeable'] !== false )
{
return false;
}
/* Push changes to the app */
$this->setStyleLastUpdated( time() );
return true;
}
/**
* Rebuild the db
*/
private function _refreshDatabase()
{
$images = $this->getImageDirContents();
/* Delete current contents */
$this->DB->delete( 'mobile_app_style' );
foreach( $images as $img )
{
if ( ! stristr( $img['filename'], $this->getRetinaSuffix() . '.png') )
{
$hasRetina = ( $this->_getFileFromArray( str_replace( '.png', $this->getRetinaSuffix() . '.png', $img['filename'] ), $images ) ) ? 1 : 0;
$insert = array( 'filename' => $img['filename'],
'isInUse' => 1,
'hasRetina' => $hasRetina,
'lastUpdated' => IPS_UNIX_TIME_NOW );
$this->DB->insert( 'mobile_app_style', $insert );
}
}
}
/**
* Fetches a file by name from the array
* @param string $file
* @param array $array
* @return array|boolean
*/
private function _getFileFromArray( $file, array $array )
{
foreach( $array as $image )
{
if ( $file == $image['filename'] )
{
return $image;
}
}
return false;
}
/**
* Fetch data from a cache
* @param string $key
* @return mixed
*/
private function _getCache( $key )
{
if ( $key && ! empty( $this->_cache[ $key ] ) )
{
return $this->_cache[ $key ];
}
return false;
}
/**
* Add an item to the local cache
* @param string $key
* @param array $value
*/
private function _addCache( $key, $value )
{
if ( $key )
{
$this->_cache[ $key ] = $value;
}
}
/**
* Flush cache
*/
private function _flushCache()
{
$this->_cache = array( 'default' => array(), 'current' => array() );
}
}
+188 -188
View File
@@ -1,189 +1,189 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Navigation Builder
* Owner: Matt Mecham
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 17th March 2011
* @version $Revision: 8644 $
*/
class classes_navigation_build
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
protected $app;
protected $extension;
/**
* Method constructor
*
* @access public
* @param string Application
* @return @e void
*
*/
public function __construct( $app='core' )
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set local data */
$this->setApp( $app );
/* Load application file */
$this->_loadExtension();
}
/**
* @return the $extension
*/
public function getExtension()
{
return $this->extension;
}
/**
* @param field_type $extension
*/
public function setExtension( $extension )
{
$this->extension = $extension;
}
/**
* @return the $app
*/
public function getApp()
{
return $this->app;
}
/**
* @param field_type $app
*/
public function setApp( $app )
{
$this->app = $app;
}
/**
* Loads the navigationd data ...
*/
public function loadApplicationTabs()
{
/* ipsRegistry::$applications only contains apps with a public title #15785 */
$appCache = ipsRegistry::cache()->getCache('app_cache');
$tabs = array();
/* Loop through applications */
foreach( $appCache as $app_dir => $app )
{
/* Only if app enabled... */
if ( $app['app_enabled'] )
{
/* Setup */
$_file = IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/navigation/generate.php';
$_class = 'navigation_' . $app['app_directory'];
/* Current app? */
if ( $app['app_directory'] == $this->getApp() )
{
$tabs[ $app['app_directory'] ] = $this->getExtension()->getTabName();
continue;
}
/* Check for the file */
if ( is_file( $_file ) )
{
/* Get the file */
$__class = IPSLib::loadLibrary( $_file, $_class, $app['app_directory'] );
/* Check for the class */
if ( class_exists( $__class ) )
{
/* Create an object */
$_obj = new $__class();
/* Check for the module */
$tabs[ $app['app_directory'] ] = $_obj->getTabName();
}
}
}
}
return $tabs;
}
/**
* Loads the navigationd data ...
*/
public function loadNavigationData()
{
return $this->getExtension()->getNavigationData();
}
/**
* Loads the current extension
*/
protected function _loadExtension()
{
/* Pointless comment! */
$_file = IPSLib::getAppDir( $this->getApp() ) . '/extensions/navigation/generate.php';
$_class = 'navigation_' . $this->getApp();
/* Otherwise create object and cache */
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, $_class, $this->getApp() );
if ( class_exists( $classToLoad ) )
{
$this->setExtension( new $classToLoad() );
}
else
{
$this->setApp('core');
$this->_loadExtension();
}
}
else
{
$this->setApp('core');
$this->_loadExtension();
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Navigation Builder
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th March 2011
* @version $Revision: 10914 $
*/
class classes_navigation_build
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
protected $app;
protected $extension;
/**
* Method constructor
*
* @access public
* @param string Application
* @return @e void
*
*/
public function __construct( $app='core' )
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set local data */
$this->setApp( $app );
/* Load application file */
$this->_loadExtension();
}
/**
* @return the $extension
*/
public function getExtension()
{
return $this->extension;
}
/**
* @param field_type $extension
*/
public function setExtension( $extension )
{
$this->extension = $extension;
}
/**
* @return the $app
*/
public function getApp()
{
return $this->app;
}
/**
* @param field_type $app
*/
public function setApp( $app )
{
$this->app = $app;
}
/**
* Loads the navigationd data ...
*/
public function loadApplicationTabs()
{
/* ipsRegistry::$applications only contains apps with a public title #15785 */
$appCache = ipsRegistry::cache()->getCache('app_cache');
$tabs = array();
/* Loop through applications */
foreach( $appCache as $app_dir => $app )
{
/* Only if app enabled... */
if ( $app['app_enabled'] )
{
/* Setup */
$_file = IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/navigation/generate.php';
$_class = 'navigation_' . $app['app_directory'];
/* Current app? */
if ( $app['app_directory'] == $this->getApp() )
{
$tabs[ $app['app_directory'] ] = $this->getExtension()->getTabName();
continue;
}
/* Check for the file */
if ( is_file( $_file ) )
{
/* Get the file */
$__class = IPSLib::loadLibrary( $_file, $_class, $app['app_directory'] );
/* Check for the class */
if ( class_exists( $__class ) )
{
/* Create an object */
$_obj = new $__class();
/* Check for the module */
$tabs[ $app['app_directory'] ] = $_obj->getTabName();
}
}
}
}
return $tabs;
}
/**
* Loads the navigationd data ...
*/
public function loadNavigationData()
{
return $this->getExtension()->getNavigationData();
}
/**
* Loads the current extension
*/
protected function _loadExtension()
{
/* Pointless comment! */
$_file = IPSLib::getAppDir( $this->getApp() ) . '/extensions/navigation/generate.php';
$_class = 'navigation_' . $this->getApp();
/* Otherwise create object and cache */
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, $_class, $this->getApp() );
if ( class_exists( $classToLoad ) )
{
$this->setExtension( new $classToLoad() );
}
else
{
$this->setApp('core');
$this->_loadExtension();
}
}
else
{
$this->setApp('core');
$this->_loadExtension();
}
}
}
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -3,17 +3,17 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Admin Output Library
* Last Updated: $LastChangedDate: 2011-10-04 08:19:01 -0400 (Tue, 04 Oct 2011) $
* Last Updated: $LastChangedDate: 2012-07-03 10:29:35 -0400 (Tue, 03 Jul 2012) $
* </pre>
*
* @author $Author: mark $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @version $Rev: 9578 $
* @link http://www.invisionpower.com
* @version $Rev: 11026 $
*
*/
@@ -107,7 +107,8 @@ class adminOutput extends output
/* Update paths and such */
$this->settings['base_url'] = $this->settings['_original_base_url'];
$this->settings['public_url'] = $this->settings['_original_base_url'] . '/index.php?';
$this->settings['public_dir'] = $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/';
$this->settings['base_acp_url'] = $this->settings['base_url'] . '/' . CP_DIRECTORY;
$this->settings['skin_acp_url'] = $this->settings['base_url'] . '/' . CP_DIRECTORY . "/skin_cp";
$this->settings['skin_app_url'] = $this->settings['skin_acp_url'] ;
@@ -248,15 +249,15 @@ class adminOutput extends output
//-----------------------------------------
// Figure out title...
//-----------------------------------------
$this->html_title = "IP.Board: ";
$this->html_title = "IP.Board:";
if ( ipsRegistry::$current_application )
{
$this->html_title .= " &gt; " . ipsRegistry::$applications[ ipsRegistry::$current_application ]['app_title'];
$this->html_title .= " " . IPSLIb::getAppTitle( ipsRegistry::$current_application );
if ( ipsRegistry::$current_module )
{
$this->html_title .= " &gt; " . ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'];
$this->html_title .= " &gt; " . ( isset($this->lang->words[ 'module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module ]) ? $this->lang->words[ 'module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module ] : ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'] );
}
}
@@ -386,7 +387,7 @@ class adminOutput extends output
* @param string Text to display
* @return @e void
*/
public function multipleRedirectFinish($text='Готово!')
public function multipleRedirectFinish($text='Completed!')
{
print $this->global_template->global_redirect_done( $text );
exit();
@@ -467,9 +468,10 @@ class adminOutput extends output
/**
* Output the HTML to the browser
*
* @param bool Return finished output instead of printing
* @return @e void
*/
public function sendOutput()
public function sendOutput( $return=false )
{
$this->_sendOutputSetUp( 'normal' );
@@ -577,11 +579,11 @@ class adminOutput extends output
if ( ipsRegistry::$current_application )
{
$this->html_title .= " &gt; " . ipsRegistry::$applications[ ipsRegistry::$current_application ]['app_title'];
$this->html_title .= " " . IPSLIb::getAppTitle( ipsRegistry::$current_application );
if ( ipsRegistry::$current_module )
{
$this->html_title .= " &gt; " . ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'];
$this->html_title .= " &gt; " . ( isset($this->lang->words[ 'module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module ]) ? $this->lang->words[ 'module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module ] : ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'] );
}
}
@@ -633,12 +635,13 @@ class adminOutput extends output
$_seen_nav[ $data[1] ] = 1;
}
$_nav = ( isset( $_last_nav['nav'] ) ) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
$_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
# Append last nav...
$_last_nav = array( 'url' => $page_location,
$_last_nav = array( 'url' => $data[0],
'title' => $data[1],
'nav' => $_nav );
if ( $data[0] )
{
$navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>";
@@ -663,13 +666,13 @@ class adminOutput extends output
$_seen_nav[ $data[1] ] = 1;
}
$_nav = ( $_last_nav['nav'] ) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
$_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' &gt; ' . $data[1] : $data[1];
# Append last nav...
$_last_nav = array( 'url' => $page_location,
$_last_nav = array( 'url' => $data[0],
'title' => $data[1],
'nav' => $_nav );
if ( $data[0] )
{
$navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>";
@@ -723,7 +726,7 @@ class adminOutput extends output
$__files = get_included_files();
$files = '';
foreach( $__files as $__f )
{
$files .= "<strong>{$__f}</strong><br />";
@@ -815,6 +818,13 @@ class adminOutput extends output
// OUTPUT
//-----------------------------------------
if( $return )
{
$this->_IS_PRINTED = 1;
return $html;
}
print $html;
$this->_IS_PRINTED = 1;
@@ -949,10 +959,10 @@ class adminOutput extends output
{
continue;
}
$_tab_title = $data['sys_module_title'];
$_tab_title = $this->lang->words[ 'module__' . $_checkApp . '_' . $data['sys_module_key'] ] ? $this->lang->words[ 'module__' . $_checkApp . '_' . $data['sys_module_key'] ] : $data['sys_module_title'];
$_tab_key = $data['sys_module_key'];
$tabs[ $_checkApp ]['items'][ $_tab_key ] = array( 'tab_title' => $_tab_title,
'tab_key' => $_tab_key );
$tabs[ $_checkApp ]['data'] = $data;
@@ -1139,9 +1149,11 @@ class adminOutput extends output
{
$skip = TRUE;
$__current_module = $_current_module;
$_current_module = preg_replace( '/^\d+?_(.*)$/', "\\1", $_current_module );
/* Fix language abstraction for module title */
$module_data['title'] = isset($this->lang->words[ 'module__' . $app_dir . '_' . $_current_module ]) ? $this->lang->words[ 'module__' . $app_dir . '_' . $_current_module ] : $module_data['title'];
/* Fake app content? If so.. remove.. */
foreach( $fakeApps as $_app => $_fdata )
{
@@ -1241,7 +1253,7 @@ class adminOutput extends output
if ( ! stristr( $this->settings['query_string_safe'], 'section=' ) )
{
$this->settings['query_string_safe'] = $this->settings[ 'query_string_safe' ] . '&amp;section=' . ipsRegistry::$request['section'];
$this->settings['query_string_safe'] = $this->settings['query_string_safe'] . '&amp;section=' . ipsRegistry::$request['section'];
}
$this->settings['query_string_safe'] = '&amp;do=' . $_do;
@@ -1284,19 +1296,21 @@ class adminOutput extends output
if ( $item['title'] AND $item['section'] )
{
$this->menu[ $app_dir ][ $__current_module ]['items'][] = array( 'title' => $item['title'],
'module' => $_current_module,
'section' => $item['section'],
'url' => $item['url'],
'redirect' => $item['redirect'] );
$this->menu[ $app_dir ][ $__current_module ]['title'] = ( count($this->menu[ $app_dir ][ $__current_module ]['items']) > 1 ) ? $module_data['title'] : $item['title'];
$this->menu[ $app_dir ][ $__current_module ]['items'][] = array( 'title' => $item['title'],
'module' => $_current_module,
'section' => $item['section'],
'url' => $item['url'],
'redirect' => $item['redirect']
);
$this->menu[ $app_dir ][ $__current_module ]['title'] = ( count($this->menu[ $app_dir ][ $__current_module ]['items']) > 1 ) ? $module_data['title'] : ( isset($this->lang->words[ 'module__' . $app_dir . '_' . $_current_module ]) ? $this->lang->words[ 'module__' . $app_dir . '_' . $_current_module ] : $item['title'] );
}
}
}
}
}
#echo "<pre>";print_r($this->menu);exit;
if ( isset( $this->menu ) && count( $this->menu ) )
{
return $this->global_template->menu_sub_navigation( $this->menu );
@@ -1352,7 +1366,7 @@ class adminOutput extends output
$this->lang->loadLanguageFile( array( 'admin_menulang' ), $app_dir );
foreach( $data as $_current_module => $module_data )
{
{
$_thisApp = $app_dir;
$__current_module = $_current_module;
$_current_module = preg_replace( '/^\d+?_(.*)$/', "\\1", $_current_module );
@@ -1401,13 +1415,13 @@ class adminOutput extends output
if ( $item['title'] AND $item['section'] )
{
$_subMenu[ $_thisApp ][ $_current_module ]['items'][] = array( 'title' => $item['title'],
'module' => $_current_module,
'section' => $item['section'],
'url' => $item['url'],
'redirect' => $item['redirect'],
'app_dir' => $app_dir,
'pos' => preg_replace( '/^(\d+)?_.*$/', "\\1", $__current_module )
$_subMenu[ $_thisApp ][ $_current_module ]['items'][] = array( 'title' => $item['title'],
'module' => $_current_module,
'section' => $item['section'],
'url' => $item['url'],
'redirect' => $item['redirect'],
'app_dir' => $app_dir,
'pos' => preg_replace( '/^(\d+)?_.*$/', "\\1", $__current_module )
);
$_subMenu[ $_thisApp ][ $_current_module ]['title'] = ( count($_subMenu[ $_thisApp ][ $_current_module ]['items']) > 1 ) ? $module_data['title'] : $item['title'];
@@ -1423,7 +1437,7 @@ class adminOutput extends output
{
foreach( ipsRegistry::$modules[ $app_dir ] as $data )
{
if ( ! $data['sys_module_admin'] )
if ( !$data['sys_module_admin'] )
{
continue;
}
@@ -1444,7 +1458,13 @@ class adminOutput extends output
}
}
}
//-----------------------------------------
// Title
//-----------------------------------------
$data['sys_module_title'] = isset($this->lang->words[ 'module__' . $app_dir . '_' . $data['sys_module_key'] ]) ? $this->lang->words[ 'module__' . $app_dir . '_' . $data['sys_module_key'] ] : $data['sys_module_title'];
$_titleMenu[ $_thisApp ][ $data['sys_module_key'] ] = array( 'url' => $this->settings['_base_url'] . 'app=' . $app_dir . '&amp;module=' . $data['sys_module_key'],
'title' => $data['sys_module_title'],
'module' => $data['sys_module_key'] );
@@ -1489,9 +1509,10 @@ class adminOutput extends output
* @param mixed Selected ID(s)
* @param boolean Multiselect (TRUE is yes)
* @param string HTML id attribute value
* @param integer Multiselect size
* @return string HTML dropdown menu
*/
public function generateGroupDropdown( $formFieldName, $selected, $multiselect=FALSE, $formFieldID='' )
public function generateGroupDropdown( $formFieldName, $selected, $multiselect=FALSE, $formFieldID='', $multiselectSize=5 )
{
//-----------------------------------------
// INIT
@@ -1512,11 +1533,11 @@ class adminOutput extends output
if ( $multiselect === TRUE )
{
return $this->formMultiDropdown( $formFieldName, $groups, $selected, 5, $formFieldID );
return $this->formMultiDropdown( $formFieldName, $groups, $selected, $multiselectSize, $formFieldID );
}
else
{
return $this->formDropdown( $formFieldName, $groups, $selected, "", $formFieldID );
return $this->formDropdown( $formFieldName, $groups, $selected, $formFieldID );
}
}
@@ -1697,7 +1718,27 @@ class adminOutput extends output
$id = $id ? $id : $name;
$html = "<select name='{$name}'{$js} id='{$id}' class='dropdown{$css}'>\n";
if ( is_string( $list ) )
{
if ( $list == '--groups--' )
{
$options = array();
$groups = $this->caches['group_cache'];
foreach( $groups as $id => $data )
{
$options[] = array( $id, $data['g_title'] );
}
$list = $options;
}
else
{
$list = array();
}
}
//-----------------------------------------
// Support for optgroups
//-----------------------------------------
@@ -1719,8 +1760,14 @@ class adminOutput extends output
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$disabled = '';
if ( isset( $v['disabled'] ) and $v['disabled'] === TRUE )
{
$disabled = ' disabled="disabled"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . $disabled . ">" . $v[1] . "</option>\n";
$_printed++;
}
@@ -1742,8 +1789,14 @@ class adminOutput extends output
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$disabled = '';
if ( isset( $v['disabled'] ) and $v['disabled'] === TRUE )
{
$disabled = ' disabled="disabled"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . $disabled . ">" . $v[1] . "</option>\n";
$_printed++;
}
@@ -1768,8 +1821,14 @@ class adminOutput extends output
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$disabled = '';
if ( isset( $v['disabled'] ) and $v['disabled'] === TRUE )
{
$disabled = ' disabled="disabled"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . $disabled . ">" . $v[1] . "</option>\n";
}
$html .= "</optgroup>\n";
@@ -1785,13 +1844,18 @@ class adminOutput extends output
foreach ( $list as $v )
{
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
{
$selected = ' selected="selected"';
}
$disabled = '';
if ( isset( $v['disabled'] ) and $v['disabled'] === TRUE )
{
$disabled = ' disabled="disabled"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$html .= "<option value='" . $v[0] . "'" . $selected . $disabled . ">" . $v[1] . "</option>\n";
}
}
@@ -1830,9 +1894,29 @@ class adminOutput extends output
$html = "<select name='{$name}'{$js} id='{$id}' class='dropdown{$css}' multiple='multiple' size='{$size}'>\n";
if ( is_string( $list ) )
{
if ( $list == '--groups--' )
{
$options = array();
$groups = $this->caches['group_cache'];
foreach( $groups as $id => $data )
{
$options[] = array( $id, $data['g_title'] );
}
$list = $options;
}
else
{
$list = array();
}
}
if ( !is_array($default) )
{
$default = array();
$default = is_string( $list ) ? array( $list ) : array();
}
foreach ($list as $v)
@@ -1843,8 +1927,14 @@ class adminOutput extends output
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$disabled = '';
if ( isset( $v['disabled'] ) and $v['disabled'] === TRUE )
{
$disabled = ' disabled="disabled"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . $disabled . ">" . $v[1] . "</option>\n";
}
$html .= "</select>\n\n";
@@ -2025,7 +2115,9 @@ class adminOutput extends output
array( 'app' => 'core',
'module' => 'posts' ),
array( 'app' => 'core',
'module' => 'languages' )
'module' => 'languages' ),
array( 'app' => 'core',
'module' => 'mobileapp' )
),
'support' => array(
array( 'app' => 'core',
File diff suppressed because it is too large. Load diff
@@ -3,19 +3,19 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2010-12-17 08:01:38 -0500 (Fri, 17 Dec 2010) $
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 7445 $
* @version $Revision: 10914 $
*
*/
$config = array();
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,28 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Ouput format: XML
* (Matt Mecham)
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*
*/
$config = array();
/* Identifies publicly as... */
$config['identifies_as'] = 'XML';
/* Gateway file? */
$config['gateway_file'] = 'xml.php';
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,365 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*
*/
class xmlOutput extends coreOutput implements interface_output
{
/**
* Main output class
*
* @access protected
* @var object
*/
protected $output;
/**
* CSS array
*
* @access protected
* @var array
*/
protected $_css = array( 'import' => array(), 'inline' => array() );
/**
* Constructor
*
* @access public
* @param object Output object
* @return @e void
*/
public function __construct( output $output )
{
/* Make object */
parent::__construct( $output );
}
/**
* Prints any header information for this output module
*
* @access public
* @return null Prints header() information
*/
public function printHeader()
{
//-----------------------------------------
// Start GZIP compression
//-----------------------------------------
if ( $this->settings['disable_gzip'] != 1 )
{
$buffer = "";
if ( count( ob_list_handlers() ) )
{
$buffer = ob_get_contents();
ob_end_clean();
}
@ob_start('ob_gzhandler');
print $buffer;
}
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
{
header("HTTP/1.0 200 OK" );
}
else
{
header("HTTP/1.1 200 OK" );
}
/* This now forces UTF-8 */
header( "Content-type: text/xml;charset=UTF-8" );
if ( $this->settings['nocache'] )
{
header("Cache-Control: no-cache, must-revalidate, max-age=0");
header("Expires: 0");
header("Pragma: no-cache");
}
}
/**
* Display error
*
* @access public
* @param string Error message
* @param integer Error code
* @return mixed You can print a custom message here, or return formatted data to be sent do registry->output->sendOutput
*/
public function displayError( $message, $code=0 )
{
}
/**
* Display board offline
*
* @access public
* @param string Message
* @return mixed You can print a custom message here, or return formatted data to be sent do registry->output->sendOutput
*/
public function displayBoardOffline( $message )
{
}
/**
* Fetches the output
*
* @access public
* @param string Output gathered
* @param string Title of the document
* @param array Navigation gathered
* @param array Array of document head items
* @param array Array of JS loader items
* @param array Array of extra data
* @return string Output to be printed to the client
*/
public function fetchOutput( $output, $title, $navigation, $documentHeadItems, $jsLoaderItems, $extraData=array() )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$system_vars_cache = $this->caches['systemvars'];
$showPMBox = '';
$currentCharSet = $this->settings['gb_char_set'];
/* Force UTF-8 for the skin */
$this->settings['gb_char_set'] = 'UTF-8';
//-----------------------------------------
// NORMAL
//-----------------------------------------
if ( $this->_outputType == 'normal' )
{
//-----------------------------------------
// Grab output
//-----------------------------------------
$finalOutput = $this->output->getTemplate('global')->globalTemplate( $output, $documentHeadItems, $this->_css, $jsLoaderItems, $this->_metaTags,
array( 'title' => $title,
'applications' => $this->core_fetchApplicationData(),
'page' => $this->_current_page_title ),
array( 'navigation' => $navigation ),
array( 'time' => $this->registry->getClass( 'class_localization')->getDate( time(), 'SHORT', 1 ),
'lang_chooser' => $this->html_buildLanguageDropDown(),
'skin_chooser' => $this->html_fetchSetsDropDown(),
'stats' => $this->html_showDebugInfo(),
'copyright' => $this->html_fetchCopyright() ),
array( 'ex_time' => sprintf( "%.4f", IPSDebug::endTimer() ),
'gzip_status' => ( $this->settings['disable_gzip'] == 1 ) ? $this->lang->words['gzip_off'] : $this->lang->words['gzip_on'],
'server_load' => ipsRegistry::$server_load,
'queries' => $this->DB->getQueryCount() )
);
}
//-----------------------------------------
// Grab output
// REDIRECT
//-----------------------------------------
else if ( $this->_outputType == 'redirect' )
{
# SEO?
if ( $extraData['seoTitle'] )
{
$extraData['url'] = $this->output->buildSEOUrl( $extraData['url'], 'none', $extraData['seoTitle'] );
$extraData['full'] = 1;
}
$finalOutput = $this->output->getTemplate('global')->redirectTemplate( $documentHeadItems, $this->_css, $jsLoaderItems, $extraData['text'], $extraData['url'], $extraData['full'] );
}
//-----------------------------------------
// POP UP
//-----------------------------------------
else if ( $this->_outputType == 'popup' )
{
$finalOutput = $this->output->getTemplate('global')->displayPopUpWindow( $documentHeadItems, $this->_css, $jsLoaderItems, $title, $output );
}
//-----------------------------------------
// Return
//-----------------------------------------
$finalOutput = $this->parseIPSTags( $finalOutput );
/* Attempt to clean HTML */
return IPSText::stripNonUtf8( IPSText::convertCharsets( $finalOutput, $currentCharSet, 'UTF-8' ) );
}
/**
* Finish / clean up after sending output
*
* @access public
* @return null
*/
public function finishUp()
{
}
/**
* Adds more items into the document header like CSS / RSS, etc
*
* @access public
* @return null
*/
public function addHeadItems()
{
}
/**
* Silent redirect (Redirects without a screen or other notification)
*
* @access public
* @param string URL
* @param string [SEO Title]
* @return mixed
*/
public function silentRedirect( $url, $seoTitle='' )
{
# Ensure &amp;s are taken care of
$url = str_replace( "&amp;", "&", $url );
# SEO?
if ( $seoTitle )
{
$url = $this->registry->getClass('output')->buildSEOUrl( $url, 'none', $seoTitle );
}
if ( $this->settings['header_redirect'] == 'refresh' )
{
@header("Refresh: 0;url=".$url);
}
else if ( $this->settings['header_redirect'] == 'html' )
{
$url = str_replace( '&', '&amp;', str_replace( '&amp;', '&', $url ) );
echo("<html><head><meta http-equiv='refresh' content='0; url=$url'></head><body></body></html>");
exit();
}
else
{
@header( "Location: ".$url );
}
exit();
}
/**
* Replace IPS tags
* Converts over <#IMG_DIR#>, etc
*
* @access public
* @param string Unparsed text
* @return string Parsed text
*/
public function parseIPSTags( $text )
{
$text = str_replace( "<#IMG_DIR#>" , $this->skin['set_image_dir'], $text );
$text = str_replace( "<#EMO_DIR#>" , $this->skin['set_emo_dir'] , $text );
$text = str_replace( "<% CHARSET %>" , IPS_DOC_CHAR_SET , $text );
$text = str_replace( "{style_image_url}", $this->settings['img_url'] , $text );
if ( $this->settings['ipb_img_url'] )
{
$text = preg_replace( '#img\s+?src=[\"\']style_(images|avatars|emoticons)(.+?)[\"\'](.+?)?'.'>#is', "img src=\"".$this->settings['ipb_img_url']."style_\\1\\2\"\\3>", $text );
}
return $text;
}
/**
* Fetch copyright notice
*
* @access protected
* @return string
*/
protected function html_fetchCopyright()
{
//-----------------------------------------
// REMOVAL OF THIS WITHOUT PURCHASING COPYRIGHT REMOVAL WILL VIOLATE THE LICENCE YOU AGREED
// TO WHEN DOWNLOADING THIS PRODUCT. THIS COULD MEAN REMOVAL OF YOUR BOARD AND EVEN
// CRIMINAL CHARGES
//-----------------------------------------
$version = ( $this->settings['ipb_display_version'] AND $this->settings['ipb_display_version'] != 0 ) ? ipsRegistry::$version : '';
if ($this->settings['ipb_copy_number'] && $this->settings['ips_cp_purchase'])
{
$copyright = "";
}
else
{
$copyright = "<!-- Copyright Information -->
<p id='copyright'>
Powered By <a href='http://www.invisionboard.com' title='IP.Board Homepage'>IP.Board</a>
{$version} &copy; ".date("Y")." &nbsp;<a href='http://www.invisionpower.com' title='IPS Homepage'>IPS, <abbr title='Incorporated'>Inc</abbr></a>.
";
if ( $this->settings['ipb_reg_name'] )
{
$copyright .= "<div>Licensed to: ". $this->settings['ipb_reg_name']."</div>";
}
$copyright .= "</p>\n\t\t<!-- / Copyright -->";
}
return $copyright;
}
/**
* Returns debug data
*
* @access protected
* @return string
*/
public function html_showDebugInfo()
{
}
/**
* Fetch language drop down box
*
* @access protected
* @return string
*/
protected function html_buildLanguageDropDown()
{
}
/**
* Fetch skin list
*
* Does what is says up there a bit
*
* @access protected
* @return HTML Drop down list. All nicely formatted.
*/
protected function html_fetchSetsDropDown()
{
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+9 -9
View File
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,121 +1,121 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2011-03-31 06:17:44 -0400 (Thu, 31 Mar 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Friday 18th March 2011
* @version $Revision: 8229 $
*/
class sabre_directory_groups extends Sabre_DAV_Directory
{
protected $_skinSet = array();
protected $_group = '';
public function __construct( $group, $skinSet )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
$this->_group = $group;
}
public function getChildren()
{
$output = array();
/* Group data or CSS */
if ( $this->_group != 'css' )
{
$templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupTemplatesNoContent', $this->_group );
/* templates */
foreach( $templates as $title => $data )
{
$output[] = new sabre_file_templates( $this->_skinSet, $data, $title, $this->_group );
}
}
else
{
$css = $this->skinFunctions->fetchCSS( $this->_skinSet['set_id'] );
/* templates */
foreach( $css as $title => $data )
{
$output[] = new sabre_file_templates( $this->_skinSet, $data, $title, 'css' );
}
}
return $output;
}
public function getChild( $title )
{
if ( ! $title || $title == '.' || strtolower( $title == '.ds_store' ) || $title == 'Thumbs.db' || $title == 'desktop.ini' )
{
return false;
}
$title = preg_replace( '#^(.*)\.(css|html)$#', '\1', $title );
/* Group data or CSS */
if ( $this->_group != 'css' )
{
/* Fetch template */
$_templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupTemplates', $this->_group );
$template = $_templates[ strtolower( $title ) ];
if ( $template )
{
return new sabre_file_templates( $this->_skinSet, $template, $title, $this->_group );
}
else
{
return new sabre_file_templates( $this->_skinSet, null, $title, $this->_group );
}
}
else
{
$css = $this->skinFunctions->fetchCSS( $this->_skinSet['set_id'] );
return new sabre_file_templates( $this->_skinSet, $css[ strtolower($title) ], $title, 'css' );
}
}
public function getName()
{
if ( strstr( $this->_group, 'skin_' ) )
{
return preg_replace( '#^skin_(.*)$#', '\1', IPSText::alphanumericalClean( $this->_group ) );
}
else if ( $this->_group == 'css' )
{
return '0.css';
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Friday 18th March 2011
* @version $Revision: 10914 $
*/
class sabre_directory_groups extends Sabre_DAV_Directory
{
protected $_skinSet = array();
protected $_group = '';
public function __construct( $group, $skinSet )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
$this->_group = $group;
}
public function getChildren()
{
$output = array();
/* Group data or CSS */
if ( $this->_group != 'css' )
{
$templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupTemplatesNoContent', $this->_group );
/* templates */
foreach( $templates as $title => $data )
{
$output[] = new sabre_file_templates( $this->_skinSet, $data, $title, $this->_group );
}
}
else
{
$css = $this->skinFunctions->fetchCSS( $this->_skinSet['set_id'] );
/* templates */
foreach( $css as $title => $data )
{
$output[] = new sabre_file_templates( $this->_skinSet, $data, $title, 'css' );
}
}
return $output;
}
public function getChild( $title )
{
if ( ! $title || $title == '.' || strtolower( $title == '.ds_store' ) || $title == 'Thumbs.db' || $title == 'desktop.ini' )
{
return false;
}
$title = preg_replace( '#^(.*)\.(css|html)$#', '\1', $title );
/* Group data or CSS */
if ( $this->_group != 'css' )
{
/* Fetch template */
$_templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupTemplates', $this->_group );
$template = $_templates[ strtolower( $title ) ];
if ( $template )
{
return new sabre_file_templates( $this->_skinSet, $template, $title, $this->_group );
}
else
{
return new sabre_file_templates( $this->_skinSet, null, $title, $this->_group );
}
}
else
{
$css = $this->skinFunctions->fetchCSS( $this->_skinSet['set_id'] );
return new sabre_file_templates( $this->_skinSet, $css[ strtolower($title) ], $title, 'css' );
}
}
public function getName()
{
if ( strstr( $this->_group, 'skin_' ) )
{
return preg_replace( '#^skin_(.*)$#', '\1', IPSText::alphanumericalClean( $this->_group ) );
}
else if ( $this->_group == 'css' )
{
return '0.css';
}
}
}
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -1,79 +1,79 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2011-03-31 06:17:44 -0400 (Thu, 31 Mar 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Friday 18th March 2011
* @version $Revision: 8229 $
*/
class sabre_directory_templates extends Sabre_DAV_Directory
{
protected $_skinSet = array();
public function __construct( $skinSet )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/groups.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
}
public function getChildren()
{
$templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupNames');
$output = array();
/* Add in css */
$output[] = new sabre_directory_groups( 'css', $this->_skinSet );
foreach( $templates as $group => $data )
{
$output[] = new sabre_directory_groups( $group, $this->_skinSet );
}
return $output;
}
public function getChild( $title )
{
if ( strstr( $title, '.css' ) )
{
return new sabre_directory_groups( 'css', $this->_skinSet );
}
else
{
return new sabre_directory_groups( 'skin_' . $title, $this->_skinSet );
}
}
public function getName()
{
return $this->_skinSet['set_id'] . '__' . IPSText::alphanumericalClean( $this->_skinSet['set_name'] );
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Friday 18th March 2011
* @version $Revision: 10914 $
*/
class sabre_directory_templates extends Sabre_DAV_Directory
{
protected $_skinSet = array();
public function __construct( $skinSet )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/groups.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
}
public function getChildren()
{
$templates = $this->skinFunctions->fetchTemplates( $this->_skinSet['set_id'], 'groupNames');
$output = array();
/* Add in css */
$output[] = new sabre_directory_groups( 'css', $this->_skinSet );
foreach( $templates as $group => $data )
{
$output[] = new sabre_directory_groups( $group, $this->_skinSet );
}
return $output;
}
public function getChild( $title )
{
if ( strstr( $title, '.css' ) )
{
return new sabre_directory_groups( 'css', $this->_skinSet );
}
else
{
return new sabre_directory_groups( 'skin_' . $title, $this->_skinSet );
}
}
public function getName()
{
return $this->_skinSet['set_id'] . '__' . IPSText::alphanumericalClean( $this->_skinSet['set_name'] );
}
}
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -1,329 +1,329 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2011-07-25 15:07:16 -0400 (Mon, 25 Jul 2011) $
* </pre>
*
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Friday 18th March 2011
* @version $Revision: 9313 $
*/
class sabre_file_templates extends Sabre_DAV_File
{
protected $_skinSet = array();
protected $_template = '';
protected $_title = '';
protected $_group = '';
protected $_content = null;
public function __construct( $skinSet, $template=null, $title=null, $group=null )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/groups.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
$this->_group = $group;
if ( $template )
{
$this->_template = $template;
$this->_title = ( $this->_group == 'css' ) ? $template['css_group'] : $template['template_name'];
}
else
{
$this->_title = $title;
}
}
public function getName()
{
return $this->_title . '.' . ( $this->_group == 'css' ? 'css' : 'html' );
}
public function getLastModified()
{
return intval( $this->_group == 'css' ? $this->_template['css_updated'] : $this->_template['template_updated'] );
}
public function getETag()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? 'new' : md5( $content );
}
public function get()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? '' : $content;
}
public function getSize()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? 0 : strlen( $content );
}
public function getContentType()
{
if ( $this->_group != 'css' )
{
return 'text/html';
}
else if ( $this->_group == 'css' )
{
return 'text/css';
}
else
{
return null;
}
}
public function put( $data )
{
$content = stream_get_contents( $data );
if ( ! $this->_title || $this->_title == '.' || strtolower( $this->_title == '.ds_store' ) || $this->_title == 'Thumbs.db' || $this->_title == 'desktop.ini' )
{
return false;
}
/* Do what now? */
return ( $this->_group == 'css' ) ? $this->_putCss( $content ) : $this->_putTemplate( $content );
}
public function delete()
{
try
{
if ( $this->_template )
{
if ( $this->_group != 'css' )
{
$this->skinFunctions->revertTemplateBit( $this->_template['template_id'], $this->_skinSet['set_id'] );
}
else
{
$this->skinFunctions->revertCSS( $this->_template['css_id'], $this->_skinSet['set_id'] );
}
}
}
catch( Exception $err )
{
/* Catch error - it might have come from a tmp save file being renamed */
if ( $this->_group != 'css' )
{
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=' . $this->_skinSet['set_id'] . ' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'',
'order' => 'template_id DESC',
'limit' => array( 0, 1 ) ) );
if ( $test['template_added_to'] > 0 && $test['template_updated'] > time() - 240 && $test['template_removable'] && $test['template_added_to'] == $this->_skinSet['set_id'] )
{
return true;
}
}
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
}
public function setName($title)
{
$title = preg_replace( '#^(.*)\.(css|html)$#', '\1', $title );
try
{
if ( $this->_group != 'css' )
{
if ( $this->_template )
{
$this->skinFunctions->renameTemplateName( $this->_template['template_id'], $title );
/* Got a master skin of the same name? Then it's a simple edit */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=0 AND template_master_key=\'' . $this->_skinSet['set_master_key'] . '\' AND template_name=\'' . $this->DB->addSlashes( $this->_title ) . '\' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'' ) );
if ( $test['template_name'] )
{
/* Reset added to */
$this->DB->update( 'skin_templates', array( 'template_added_to' => 0 ), 'template_id=' . $this->_template['template_id'] );
}
}
}
else
{
if ( $this->_template )
{
$this->skinFunctions->renameCssName( $this->_template['css_id'], $title );
}
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
/**
* Put CSS
* @param string $content
* @throws Sabre_DAV_Exception_Forbidden
* @return boolean
*/
protected function _putCss( $content )
{
/* Clear cache */
$this->_content = null;
/* Save it! */
try
{
if ( ! empty( $this->_template['css_id'] ) && $this->_skinSet['set_id'] )
{
$this->skinFunctions->saveCSSFromEdit( $this->_template['css_id'], $this->_skinSet['set_id'], $content, $this->_title, $this->_template['css_position'], $this->_template['css_attributes'], $this->_template['css_app'], $this->_template['css_app_hide'], $this->_template['css_modules'] );
}
else
{
$this->skinFunctions->saveCSSFromAdd( $this->_skinSet['set_id'], $content, $this->_title, $this->_template['css_position'], $this->_template['css_attributes'], $this->_template['css_app'], $this->_template['css_app_hide'], $this->_template['css_modules'] );
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
/**
* Put template ...
* @param string $content
* @throws Sabre_DAV_Exception_Forbidden
* @return boolean
*/
protected function _putTemplate( $content )
{
/* Got a data tag? */
$params = '';
$template = '';
if ( stristr( $content, '<ips:template parameters="' ) )
{
preg_match( '#<ips:template parameters="(.+?)" />(\n)?#', $content, $match );
if ( $match[1] )
{
$params = $match[1];
$template = str_replace( $match[0], '', $content );
}
}
else
{
$template = $content;
}
/* Clear cache */
$this->_content = null;
/* Save it! */
try
{
if ( ! empty( $this->_template['template_id'] ) && $this->_skinSet['set_id'] )
{
$this->skinFunctions->saveTemplateBitFromEdit( $this->_template['template_id'], $this->_skinSet['set_id'], $template, $params );
}
else
{
$newId = $this->skinFunctions->saveTemplateBitFromAdd( $this->_skinSet['set_id'], $template, $params, $this->_group, $this->_title );
/* If webdav client adds, then renames… - in delete, if trying to delete master and set specific exists, allow without error but don't delete */
if ( $newId )
{
/* Got a master skin of the same name? Then it's a simple edit */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=0 AND template_master_key=\'' . $this->_skinSet['set_master_key'] . '\' AND template_name=\'' . $this->DB->addSlashes( $this->_title ) . '\' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'' ) );
if ( $test['template_name'] )
{
/* Update new */
$this->DB->update( 'skin_templates', array( 'template_set_id' => $this->_skinSet['set_id'], 'template_master_key' => '' ), 'template_id=' . $newId );
$this->_template['template_set_id'] = $this->_skinSet['set_id'];
$this->_template['template_id'] = $newId;
}
}
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
protected function _getTemplateContent()
{
if ( ! $this->_template )
{
return false;
}
if ( $this->_content === null )
{
if ( $this->_group != 'css' )
{
$template = $this->skinFunctions->fetchTemplateBitForEdit( $this->_template['template_id'], $this->_skinSet['set_id'] );
$data = $template['template_data'];
if ( ! empty( $data ) )
{
$template['_template_content'] = '<ips:template parameters="' . IPSText::formToText( $data ) . '" />' . "\n" . $template['_template_content'];
}
$this->_content = ( isset( $template['_template_content'] ) ) ? $template['_template_content'] : false;
}
else
{
$template = $this->skinFunctions->fetchCSSForEdit( $this->_template['css_id'], $this->_skinSet['set_id'] );
$this->_content = ( isset( $template['css_content'] ) ) ? $template['css_content'] : false;
}
}
return $this->_content;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Friday 18th March 2011
* @version $Revision: 10914 $
*/
class sabre_file_templates extends Sabre_DAV_File
{
protected $_skinSet = array();
protected $_template = '';
protected $_title = '';
protected $_group = '';
protected $_content = null;
public function __construct( $skinSet, $template=null, $title=null, $group=null )
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/groups.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
$this->_skinSet = $skinSet;
$this->_group = $group;
if ( $template )
{
$this->_template = $template;
$this->_title = ( $this->_group == 'css' ) ? $template['css_group'] : $template['template_name'];
}
else
{
$this->_title = $title;
}
}
public function getName()
{
return $this->_title . '.' . ( $this->_group == 'css' ? 'css' : 'html' );
}
public function getLastModified()
{
return intval( $this->_group == 'css' ? $this->_template['css_updated'] : $this->_template['template_updated'] );
}
public function getETag()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? 'new' : md5( $content );
}
public function get()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? '' : $content;
}
public function getSize()
{
$content = $this->_getTemplateContent();
return ( $content === false ) ? 0 : strlen( $content );
}
public function getContentType()
{
if ( $this->_group != 'css' )
{
return 'text/html';
}
else if ( $this->_group == 'css' )
{
return 'text/css';
}
else
{
return null;
}
}
public function put( $data )
{
$content = stream_get_contents( $data );
if ( ! $this->_title || $this->_title == '.' || strtolower( $this->_title == '.ds_store' ) || $this->_title == 'Thumbs.db' || $this->_title == 'desktop.ini' )
{
return false;
}
/* Do what now? */
return ( $this->_group == 'css' ) ? $this->_putCss( $content ) : $this->_putTemplate( $content );
}
public function delete()
{
try
{
if ( $this->_template )
{
if ( $this->_group != 'css' )
{
$this->skinFunctions->revertTemplateBit( $this->_template['template_id'], $this->_skinSet['set_id'] );
}
else
{
$this->skinFunctions->revertCSS( $this->_template['css_id'], $this->_skinSet['set_id'] );
}
}
}
catch( Exception $err )
{
/* Catch error - it might have come from a tmp save file being renamed */
if ( $this->_group != 'css' )
{
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=' . $this->_skinSet['set_id'] . ' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'',
'order' => 'template_id DESC',
'limit' => array( 0, 1 ) ) );
if ( $test['template_added_to'] > 0 && $test['template_updated'] > time() - 240 && $test['template_removable'] && $test['template_added_to'] == $this->_skinSet['set_id'] )
{
return true;
}
}
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
}
public function setName($title)
{
$title = preg_replace( '#^(.*)\.(css|html)$#', '\1', $title );
try
{
if ( $this->_group != 'css' )
{
if ( $this->_template )
{
$this->skinFunctions->renameTemplateName( $this->_template['template_id'], $title );
/* Got a master skin of the same name? Then it's a simple edit */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=0 AND template_master_key=\'' . $this->_skinSet['set_master_key'] . '\' AND template_name=\'' . $this->DB->addSlashes( $this->_title ) . '\' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'' ) );
if ( $test['template_name'] )
{
/* Reset added to */
$this->DB->update( 'skin_templates', array( 'template_added_to' => 0 ), 'template_id=' . $this->_template['template_id'] );
}
}
}
else
{
if ( $this->_template )
{
$this->skinFunctions->renameCssName( $this->_template['css_id'], $title );
}
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
/**
* Put CSS
* @param string $content
* @throws Sabre_DAV_Exception_Forbidden
* @return boolean
*/
protected function _putCss( $content )
{
/* Clear cache */
$this->_content = null;
/* Save it! */
try
{
if ( ! empty( $this->_template['css_id'] ) && $this->_skinSet['set_id'] )
{
$this->skinFunctions->saveCSSFromEdit( $this->_template['css_id'], $this->_skinSet['set_id'], $content, $this->_title, $this->_template['css_position'], $this->_template['css_attributes'], $this->_template['css_app'], $this->_template['css_app_hide'], $this->_template['css_modules'] );
}
else
{
$this->skinFunctions->saveCSSFromAdd( $this->_skinSet['set_id'], $content, $this->_title, $this->_template['css_position'], $this->_template['css_attributes'], $this->_template['css_app'], $this->_template['css_app_hide'], $this->_template['css_modules'] );
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
/**
* Put template ...
* @param string $content
* @throws Sabre_DAV_Exception_Forbidden
* @return boolean
*/
protected function _putTemplate( $content )
{
/* Got a data tag? */
$params = '';
$template = '';
if ( stristr( $content, '<ips:template parameters="' ) )
{
preg_match( '#<ips:template parameters="(.+?)" />(\n)?#', $content, $match );
if ( $match[1] )
{
$params = $match[1];
$template = str_replace( $match[0], '', $content );
}
}
else
{
$template = $content;
}
/* Clear cache */
$this->_content = null;
/* Save it! */
try
{
if ( ! empty( $this->_template['template_id'] ) && $this->_skinSet['set_id'] )
{
$this->skinFunctions->saveTemplateBitFromEdit( $this->_template['template_id'], $this->_skinSet['set_id'], $template, $params );
}
else
{
$newId = $this->skinFunctions->saveTemplateBitFromAdd( $this->_skinSet['set_id'], $template, $params, $this->_group, $this->_title );
/* If webdav client adds, then renames... - in delete, if trying to delete master and set specific exists, allow without error but don't delete */
if ( $newId )
{
/* Got a master skin of the same name? Then it's a simple edit */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=0 AND template_master_key=\'' . $this->_skinSet['set_master_key'] . '\' AND template_name=\'' . $this->DB->addSlashes( $this->_title ) . '\' AND template_group=\'' . $this->DB->addSlashes( $this->_group ) . '\'' ) );
if ( $test['template_name'] )
{
/* Update new */
$this->DB->update( 'skin_templates', array( 'template_set_id' => $this->_skinSet['set_id'], 'template_master_key' => '' ), 'template_id=' . $newId );
$this->_template['template_set_id'] = $this->_skinSet['set_id'];
$this->_template['template_id'] = $newId;
}
}
}
}
catch( Exception $err )
{
throw new Sabre_DAV_Exception_Forbidden( $err->getMessage() );
}
return true;
}
protected function _getTemplateContent()
{
if ( ! $this->_template )
{
return false;
}
if ( $this->_content === null )
{
if ( $this->_group != 'css' )
{
$template = $this->skinFunctions->fetchTemplateBitForEdit( $this->_template['template_id'], $this->_skinSet['set_id'] );
$data = $template['template_data'];
if ( ! empty( $data ) )
{
$template['_template_content'] = '<ips:template parameters="' . IPSText::formToText( $data ) . '" />' . "\n" . $template['_template_content'];
}
$this->_content = ( isset( $template['_template_content'] ) ) ? $template['_template_content'] : false;
}
else
{
$template = $this->skinFunctions->fetchCSSForEdit( $this->_template['css_id'], $this->_skinSet['set_id'] );
$this->_content = ( isset( $template['css_content'] ) ) ? $template['css_content'] : false;
}
}
return $this->_content;
}
}
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -1,35 +1,35 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2011-03-31 06:17:44 -0400 (Thu, 31 Mar 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Friday 18th March 2011
* @version $Revision: 8229 $
*/
class sabre_lock_nolocks extends Sabre_DAV_Locks_Backend_Abstract
{
public function getLocks( $uri )
{
return array();
}
public function lock( $uri, Sabre_DAV_Locks_LockInfo $lockInfo )
{
return true;
}
public function unlock( $uri, Sabre_DAV_Locks_LockInfo $lockInfo )
{
return true;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Friday 18th March 2011
* @version $Revision: 10914 $
*/
class sabre_lock_nolocks extends Sabre_DAV_Locks_Backend_Abstract
{
public function getLocks( $uri )
{
return array();
}
public function lock( $uri, Sabre_DAV_Locks_LockInfo $lockInfo )
{
return true;
}
public function unlock( $uri, Sabre_DAV_Locks_LockInfo $lockInfo )
{
return true;
}
}
@@ -1,10 +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.invisionpower.com/">IP.Board</a>
</body>
<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.invisionpower.com/">IP.Board</a>
</body>
</html>
@@ -1,78 +1,78 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2011-03-31 06:17:44 -0400 (Thu, 31 Mar 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Friday 18th March 2011
* @version $Revision: 8229 $
*/
class sabre_root_skins extends Sabre_DAV_Directory
{
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
}
public function getChildren()
{
/* Show all skins */
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'order' => 'set_id ASC' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$output[] = new sabre_directory_templates( $row );
}
return $output;
}
public function getChild( $directoryName )
{
/* Fetch ID */
$skinId = preg_replace( '#^([0-9]+?)__.*$#', '\1', $directoryName );
if ( is_numeric( $skinId ) )
{
$skinSet = $this->skinFunctions->fetchSkinData( intval( $skinId ) );
return new sabre_directory_templates( $skinSet );
}
}
public function getName()
{
return 'PublicTemplates';
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sabre classes by Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Friday 18th March 2011
* @version $Revision: 10914 $
*/
class sabre_root_skins extends Sabre_DAV_Directory
{
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Require some files for our sabre implementation */
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
$this->skinFunctions = new skinCaching( $this->registry );
}
public function getChildren()
{
/* Show all skins */
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'order' => 'set_id ASC' ) );
$o = $this->DB->execute();
while( $row = $this->DB->fetch( $o ) )
{
$output[] = new sabre_directory_templates( $row );
}
return $output;
}
public function getChild( $directoryName )
{
/* Fetch ID */
$skinId = preg_replace( '#^([0-9]+?)__.*$#', '\1', $directoryName );
if ( is_numeric( $skinId ) )
{
$skinSet = $this->skinFunctions->fetchSkinData( intval( $skinId ) );
return new sabre_directory_templates( $skinSet );
}
}
public function getName()
{
return 'PublicTemplates';
}
}
File diff suppressed because it is too large. Load diff
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,333 +1,357 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Global Search
* Last Updated: $Date: 2011-08-08 07:05:57 -0400 (Mon, 08 Aug 2011) $
* </pre>
*
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://hatynka.in
* @version $Rev: 9376 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_engine
{
/**
* Date range restriction start
*
* @access protected
* @var integer
*/
protected $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access protected
* @var integer
*/
protected $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access protected
* @var array
*/
protected $whereConditions = array();
/**
* Sphinx client object
*
* @access public
* @var object
*/
public $sphinxClient;
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Do we have the sphinxes? */
if( ! is_file( 'sphinxapi.php' ) )
{
$registry->output->showError( 'sphinx_api_missing', 10182 );
}
/* Load Sphinx */
require( 'sphinxapi.php' );/*noLibHook*/
$this->sphinxClient = new SphinxClient();
$this->sphinxClient->SetServer( $this->settings['search_sphinx_server'], intval( $this->settings['search_sphinx_port'] ) );
$this->sphinxClient->SetMatchMode( SPH_MATCH_EXTENDED );
$this->sphinxClient->SetLimits( 0, 1000 );
}
/**
* Perform a search.
* Returns an array of a total count (total number of matches)
* and an array of IDs matching the required number based on pagination. The ids returned would be based on the filters and type of search
*
* So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
*
* @access public
* @return array
*/
public function search()
{
/* Per app class handles this */
throw new Exception("NO_SEARCH_AVAILABLE");
}
/**
* Perform the viewNewContent search
* Generic version
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewNewContent()
{
$app = IPSSearchRegistry::get('in.search_app');
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
/* Set time stamp */
$this->setDateRange( intval( time() - $seconds ), time() );
/* Force title search only */
IPSSearchRegistry::set('opt.searchTitleOnly', true);
return $this->search();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewUserContent( $member )
{
$app = IPSSearchRegistry::get('in.search_app');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
IPSSearchRegistry::set('opt.noPostPreview' , IPSSearchRegistry::get('in.view_by_title') );
/* Set the member_id */
$this->setCondition( 'member_id', '=', $member['member_id'] );
/* Cut by date for efficiency? */
if ( $this->settings['search_ucontent_days'] )
{
$begin = ( $member['last_post'] ? $member['last_post'] : time() ) - 86400 * intval( $this->settings['search_ucontent_days'] );
$this->setDateRange( $begin, time() );
}
return $this->search();
}
/**
* Can handle boolean searching
*
* @access public
* @return boolean
*/
public function isBoolean()
{
return TRUE;
}
/**
* Formats search term for SQL
*
* @access private
* @param string Raw IPB santized form input
* @return array array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
*/
public function formatSearchTerm( $search_term )
{
$isBoolean = $this->isBoolean();
$andor = isset( $this->request['andor_type'] ) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
$removedTerms = array();
/* Fix up some sanitized HTML */
$search_term = str_replace( "&amp;" , '&' , IPSText::parseCleanValue( rawurldecode( $search_term ) ) );
$search_term = str_replace( "&quot;" , '"' , $search_term );
$search_term = IPSText::mbstrtolower( $search_term );
/* Check for disallowed search terms */
while( preg_match_all( '/(?:^|\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\s+|$)/', $search_term, $removed_search_terms ) )
{
$removedTerms[] = $removed_search_terms[0][0];
$search_term = preg_replace( '/(^|\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\s+|$)/', str_replace( " ", " ", "$1$2" ), $search_term );
}
/* Remove some formatting */
//$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
// | is an OR operator for sphinx - don't want to block globally
$search_term = str_replace( array( '\\', '/' ), '', $search_term );
/* Sphinx chars are not allowed */
$search_term = str_replace( array( '.', ')', '(', '!', '@', '[', ']', '-', '~', '^' ), '', $search_term );
if ( $andor == 'or' )
{
$search_term = preg_replace( '/\s+/', " | ", $search_term );
}
return array( 'search_term' => $search_term, 'removed' => $removedTerms );
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return @e void
*/
public function setDateRange( $begin, $end=0 )
{
$begin = ( $begin < 1000000000 ) ? 1000000000 : $begin;
$this->search_begin_timestamp = $begin;
$this->search_end_timestamp = $end;
}
/**
* Remap standard columns (Apps can override )
*
* @access public
* @param string $column sql table column for this condition
* @return string column
* @return @e void
*/
public function remapColumn( $column )
{
return $column;
}
/**
* mySQL function for adding special search conditions
*
* @access public
* @param string $column sql table column for this condition
* @param string $operator Operation to perform for this condition, ex: =, <>, IN, NOT IN
* @param mixed $value Value to check with
* @param string $comp Comparison type
* @return @e void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
/* This is restricted by the indexes searched */
if( $column == 'app' )
{
return;
}
$column = $this->remapColumn( $column );
if( !$column )
{
return;
}
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
$this->sphinxClient->setFilter( $column, explode( ',', $value ) );
break;
case 'NOT IN':
$this->sphinxClient->setFilter( $column, explode( ',', $value ), TRUE );
break;
case '=':
$this->sphinxClient->setFilter( $column, array( $value ) );
break;
case '!=':
case '<>':
$this->sphinxClient->setFilter( $column, array( $value ), TRUE );
break;
default:
echo "<b>Unhandled sphinx search operator: {$operator}</b><br />";
break;
}
}
/**
* Allows you to specify multiple conditions that are chained together
*
* @access public
* @param array $conditions Array of conditions, each element has 3 keys: column, operator, value, see the setCondition function for information on each
* @param string $inner_comp Comparison operator to use inside the chain
* @param string $outer_comp Comparison operator to use outside the chain
* @return @e void
*/
public function setMultiConditions( $conditions, $inner_comp='OR', $outer_comp='AND' )
{
/* Loop through the conditions to build the statement */
return;
}
/**
* Checks and logs any errors
*
* @access public
* @return @e void
*/
public function logSphinxWarnings()
{
$error = $this->sphinxClient->GetLastError();
$warning = $this->sphinxClient->GetLastWarning();
if ( $error )
{
IPSDebug::addLogMessage( "Sphinx Error: $error", 'sphinx_error_' . date('m_d_y'), $error, TRUE );
}
if ( $warning )
{
IPSDebug::addLogMessage( "Sphinx Warning: $warning", 'sphinx_warning_' . date('m_d_y'), $warning, TRUE );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Global Search
* Last Updated: $Date: 2012-06-21 12:05:17 -0400 (Thu, 21 Jun 2012) $
* </pre>
*
* @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 10967 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_engine
{
/**
* Date range restriction start
*
* @access protected
* @var integer
*/
protected $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access protected
* @var integer
*/
protected $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access protected
* @var array
*/
protected $whereConditions = array();
/**
* Sphinx client object
*
* @access public
* @var object
*/
public $sphinxClient;
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Do we have the sphinxes? */
if( ! is_file( DOC_IPS_ROOT_PATH . 'sphinxapi.php' ) )
{
$registry->output->showError( 'sphinx_api_missing', 10182 );
}
/* Load Sphinx */
require_once( DOC_IPS_ROOT_PATH . 'sphinxapi.php' );/*noLibHook*/
$this->sphinxClient = new SphinxClient();
$this->sphinxClient->SetServer( $this->settings['search_sphinx_server'], intval( $this->settings['search_sphinx_port'] ) );
$this->sphinxClient->SetMatchMode( SPH_MATCH_EXTENDED );
$this->sphinxClient->SetLimits( 0, 1000 );
}
/**
* Perform a search.
* Returns an array of a total count (total number of matches)
* and an array of IDs matching the required number based on pagination. The ids returned would be based on the filters and type of search
*
* So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
*
* @access public
* @return array
*/
public function search()
{
/* Per app class handles this */
throw new Exception("NO_SEARCH_AVAILABLE");
}
/**
* Perform the viewNewContent search
* Generic version
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewNewContent()
{
$app = IPSSearchRegistry::get('in.search_app');
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
/* Set time stamp */
$this->setDateRange( intval( time() - $seconds ), time() );
/* Force title search only */
IPSSearchRegistry::set('opt.searchTitleOnly', true);
return $this->search();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewUserContent( $member )
{
$app = IPSSearchRegistry::get('in.search_app');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
IPSSearchRegistry::set('opt.noPostPreview' , IPSSearchRegistry::get('in.view_by_title') );
/* Set the member_id */
$this->setCondition( 'member_id', '=', $member['member_id'] );
/* Cut by date for efficiency? */
if ( $this->settings['search_ucontent_days'] )
{
$begin = ( $member['last_post'] ? $member['last_post'] : time() ) - 86400 * intval( $this->settings['search_ucontent_days'] );
$this->setDateRange( $begin, time() );
}
return $this->search();
}
/**
* Can handle boolean searching
*
* @access public
* @return boolean
*/
public function isBoolean()
{
return TRUE;
}
/**
* Formats search term for SQL
*
* @access private
* @param string Raw IPB santized form input
* @return array array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
*/
public function formatSearchTerm( $search_term )
{
$isBoolean = $this->isBoolean();
$andor = isset( $this->request['andor_type'] ) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
$removedTerms = array();
/* Fix up some sanitized HTML */
$search_term = str_replace( "&amp;" , '&' , IPSText::parseCleanValue( rawurldecode( $search_term ) ) );
$search_term = str_replace( "&quot;" , '"' , $search_term );
$search_term = IPSText::mbstrtolower( $search_term );
/* Check for disallowed search terms */
while( preg_match_all( '/(?:^|\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\s+|$)/', $search_term, $removed_search_terms ) )
{
$removedTerms[] = $removed_search_terms[0][0];
$search_term = preg_replace( '/(^|\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\s+|$)/', str_replace( " ", " ", "$1$2" ), $search_term );
}
/* remove < min char words */
if ( substr_count( $search_term, '"' ) != 2 )
{
$_words = explode( ' ', $search_term );
$search_term = '';
foreach( $_words as $_w )
{
if ( IPSText::mbstrlen( $_w ) >= $this->settings['min_search_word'] )
{
$search_term .= $_w . ' ';
}
else
{
$removedTerms[] = $_w;
}
}
}
/* Remove some formatting */
//$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
// | is an OR operator for sphinx - don't want to block globally
if ( $search_term )
{
$search_term = str_replace( array( '\\', '/' ), '', trim( $search_term ) );
/* Sphinx chars are not allowed */
$search_term = str_replace( array( '.', ')', '(', '!', '@', '[', ']', '~', '^' ), '', $search_term );
$search_term = preg_replace('#(?!\s)-#', '\1&#8208', $search_term );
if ( $andor == 'and' AND ! ( substr_count( $search_term, '"' ) == 2 ) )
{
$search_term = '+' . preg_replace( '/\s+(?!-|~)/', " +", $search_term );
}
}
return array( 'search_term' => $search_term, 'removed' => $removedTerms );
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return @e void
*/
public function setDateRange( $begin, $end=0 )
{
$begin = ( $begin < 1000000000 ) ? 1000000000 : $begin;
$this->search_begin_timestamp = $begin;
$this->search_end_timestamp = $end;
}
/**
* Remap standard columns (Apps can override )
*
* @access public
* @param string $column sql table column for this condition
* @return string column
* @return @e void
*/
public function remapColumn( $column )
{
return $column;
}
/**
* mySQL function for adding special search conditions
*
* @access public
* @param string $column sql table column for this condition
* @param string $operator Operation to perform for this condition, ex: =, <>, IN, NOT IN
* @param mixed $value Value to check with
* @param string $comp Comparison type
* @return @e void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
/* This is restricted by the indexes searched */
if( $column == 'app' )
{
return;
}
$column = $this->remapColumn( $column );
if( !$column )
{
return;
}
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
$this->sphinxClient->setFilter( $column, explode( ',', $value ) );
break;
case 'NOT IN':
$this->sphinxClient->setFilter( $column, explode( ',', $value ), TRUE );
break;
case '=':
$this->sphinxClient->setFilter( $column, array( $value ) );
break;
case '!=':
case '<>':
$this->sphinxClient->setFilter( $column, array( $value ), TRUE );
break;
default:
echo "<b>Unhandled sphinx search operator: {$operator}</b><br />";
break;
}
}
/**
* Allows you to specify multiple conditions that are chained together
*
* @access public
* @param array $conditions Array of conditions, each element has 3 keys: column, operator, value, see the setCondition function for information on each
* @param string $inner_comp Comparison operator to use inside the chain
* @param string $outer_comp Comparison operator to use outside the chain
* @return @e void
*/
public function setMultiConditions( $conditions, $inner_comp='OR', $outer_comp='AND' )
{
/* Loop through the conditions to build the statement */
return;
}
/**
* Checks and logs any errors
*
* @access public
* @return @e void
*/
public function logSphinxWarnings()
{
$error = $this->sphinxClient->GetLastError();
$warning = $this->sphinxClient->GetLastWarning();
if ( $error )
{
IPSDebug::addLogMessage( "Sphinx Error: $error", 'sphinx_error_' . date('m_d_y'), $error, TRUE );
}
if ( $warning )
{
IPSDebug::addLogMessage( "Sphinx Warning: $warning", 'sphinx_warning_' . date('m_d_y'), $warning, TRUE );
}
}
}
@@ -1,305 +1,324 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Global Search
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://hatynka.in
* @version $Rev: 8644 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_engine
{
/**
* Date range restriction start
*
* @access protected
* @var integer
*/
protected $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access protected
* @var integer
*/
protected $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access protected
* @var array
*/
protected $whereConditions = array();
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Perform a search.
* Returns an array of a total count (total number of matches)
* and an array of IDs matching the required number based on pagination. The ids returned would be based on the filters and type of search
*
* So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
*
* @access public
* @return array
*/
public function search()
{
/* Per app class handles this */
throw new Exception("NO_SEARCH_AVAILABLE");
}
/**
* Perform the viewNewContent search
* Generic version
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewNewContent()
{
$app = IPSSearchRegistry::get('in.search_app');
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
/* Set time stamp */
$this->setDateRange( intval( time() - $seconds ), time() );
/* Force title search only */
IPSSearchRegistry::set('opt.searchTitleOnly', true);
return $this->search();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewUserContent( $member )
{
$app = IPSSearchRegistry::get('in.search_app');
//IPSSearchRegistry::set('in.search_sort_by' , 'date' );
//IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
IPSSearchRegistry::set('opt.noPostPreview' , IPSSearchRegistry::get('in.view_by_title') );
/* Set the member_id */
$this->setCondition( 'member_id', '=', $member['member_id'] );
/* Cut by date for efficiency? */
if ( $this->settings['search_ucontent_days'] )
{
$begin = time() - ( 86400 * intval( $this->settings['search_ucontent_days'] ) );
$this->setDateRange( $begin, time() );
}
return $this->search();
}
/**
* Can handle boolean searching
*
* @access public
* @return boolean
*/
public function isBoolean()
{
return ( $this->settings['use_fulltext'] AND $this->DB->checkBooleanFulltextSupport() ) ? TRUE : FALSE;
}
/**
* Formats search term for SQL
*
* @access private
* @param string Raw IPB santized form input
* @return array array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
*/
public function formatSearchTerm( $search_term )
{
$isBoolean = $this->isBoolean();
$andor = !empty( $this->request['andor_type'] ) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
$removedTerms = array();
/* Fix up some sanitized HTML */
$search_term = str_replace( "&amp;" , '&' , IPSText::parseCleanValue( rawurldecode( $search_term ) ) );
if( $isBoolean )
{
$search_term = str_replace( "&quot;" , '"' , $search_term );
}
else
{
$search_term = str_replace( "&quot;" , '' , $search_term );
}
$search_term = IPSText::mbstrtolower( $search_term );
/* Check for disallowed search terms */
while( preg_match_all( '/(?:^|\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\s+|$)/', $search_term, $removed_search_terms ) )
{
$removedTerms[] = $removed_search_terms[0][0];
$search_term = preg_replace( '/(^|\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\s+|$)/', str_replace( " ", " ", "$1$2" ), $search_term );
}
/* Remove some formatting */
//$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
// | is an OR operator for sphinx - don't want to block globally
$search_term = str_replace( array( '\\', '/' ), '', $search_term );
/* got some bullean to do? */
if ( $isBoolean AND strstr( $search_term, ' ' ) AND ! strstr( $search_term, '"' ) )
{
if ( $andor == 'and' )
{
$search_term = '+' . preg_replace( '/\s+(?!-|~)/', " +", $search_term );
}
}
return array( 'search_term' => $search_term, 'removed' => $removedTerms );
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return @e void
*/
public function setDateRange( $begin, $end=0 )
{
$this->search_begin_timestamp = $begin;
$this->search_end_timestamp = $end;
}
/**
* mySQL function for adding special search conditions
*
* @access public
* @param string $column sql table column for this condition
* @param string $operator Operation to perform for this condition, ex: =, <>, IN, NOT IN
* @param mixed $value Value to check with
* @param string $comp Comparison type
* @return @e void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
$column = $this->remapColumn( $column );
if ( $column == 'app' OR ! $column )
{
return;
}
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
case 'NOT IN':
$this->whereConditions[$comp][] = "{$column} {$operator} ( {$value} )";
break;
default:
$this->whereConditions[$comp][] = "{$column} {$operator} {$value}";
break;
}
}
/**
* Remap standard columns (Apps can override )
*
* @access public
* @param string $column sql table column for this condition
* @return string column
* @return @e void
*/
public function remapColumn( $column )
{
return $column;
}
/**
* Allows you to specify multiple conditions that are chained together
*
* @access public
* @param array $conditions Array of conditions, each element has 3 keys: column, operator, value, see the setCondition function for information on each
* @param string $inner_comp Comparison operator to use inside the chain
* @param string $outer_comp Comparison operator to use outside the chain
* @return @e void
*/
public function setMultiConditions( $conditions, $inner_comp='OR', $outer_comp='AND' )
{
/* Loop through the conditions to build the statement */
$_temp = array();
foreach( $conditions as $r )
{
/* REMAP */
$r['column'] = $r['column'] == 'type_id' ? 't.forum_id' : $r['column'];
if( $r['column'] == 'app' )
{
continue;
}
switch( strtoupper( $r['operator'] ) )
{
case 'IN':
case 'NOT IN':
$_temp[] = "{$r['column']} {$r['operator']} ( {$r['value']} )";
break;
default:
$_temp[] = "{$r['column']} {$r['operator']} {$r['value']}";
break;
}
}
$this->whereConditions[$outer_comp][] = '( ' . implode( $_temp, ' ' . $inner_comp . ' ' ) . ' ) ';
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Global Search
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_engine
{
/**
* Date range restriction start
*
* @access protected
* @var integer
*/
protected $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access protected
* @var integer
*/
protected $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access protected
* @var array
*/
protected $whereConditions = array();
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Perform a search.
* Returns an array of a total count (total number of matches)
* and an array of IDs matching the required number based on pagination. The ids returned would be based on the filters and type of search
*
* So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
*
* @access public
* @return array
*/
public function search()
{
/* Per app class handles this */
throw new Exception("NO_SEARCH_AVAILABLE");
}
/**
* Perform the viewNewContent search
* Generic version
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewNewContent()
{
$app = IPSSearchRegistry::get('in.search_app');
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
/* Set time stamp */
$this->setDateRange( intval( time() - $seconds ), time() );
/* Force title search only */
IPSSearchRegistry::set('opt.searchTitleOnly', true);
return $this->search();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewUserContent( $member )
{
$app = IPSSearchRegistry::get('in.search_app');
//IPSSearchRegistry::set('in.search_sort_by' , 'date' );
//IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
IPSSearchRegistry::set('opt.noPostPreview' , IPSSearchRegistry::get('in.view_by_title') );
/* Set the member_id */
$this->setCondition( 'member_id', '=', $member['member_id'] );
/* Cut by date for efficiency? */
if ( $this->settings['search_ucontent_days'] )
{
$begin = time() - ( 86400 * intval( $this->settings['search_ucontent_days'] ) );
$this->setDateRange( $begin, time() );
}
return $this->search();
}
/**
* Can handle boolean searching
*
* @access public
* @return boolean
*/
public function isBoolean()
{
return ( $this->settings['use_fulltext'] AND $this->DB->checkBooleanFulltextSupport() ) ? TRUE : FALSE;
}
/**
* Formats search term for SQL
*
* @access private
* @param string Raw IPB santized form input
* @return array array( 'search_term' => Safe string to use in SQL, 'removed' => array of removed search terms )
*/
public function formatSearchTerm( $search_term )
{
$isBoolean = $this->isBoolean();
$andor = !empty( $this->request['andor_type'] ) ? $this->request['andor_type'] : $this->settings['s_andor_type'];
$removedTerms = array();
/* Fix up some sanitized HTML */
$search_term = str_replace( "&amp;" , '&' , IPSText::parseCleanValue( rawurldecode( $search_term ) ) );
if( $isBoolean )
{
$search_term = str_replace( "&quot;" , '"' , $search_term );
}
else
{
$search_term = str_replace( "&quot;" , '' , $search_term );
}
$search_term = IPSText::mbstrtolower( $search_term );
/* Check for disallowed search terms */
while( preg_match_all( '/(?:^|\s+)(img|quote|code|html|javascript|a href|color|span|div|border|style)(?:\s+|$)/', $search_term, $removed_search_terms ) )
{
$removedTerms[] = $removed_search_terms[0][0];
$search_term = preg_replace( '/(^|\s+)(?:img|quote|code|html|javascript|a href|color|span|div|border|style)(\s+|$)/', str_replace( " ", " ", "$1$2" ), $search_term );
}
/* remove < min char words */
if ( substr_count( $search_term, '"' ) != 2 )
{
$_words = explode( ' ', $search_term );
$search_term = '';
foreach( $_words as $_w )
{
if ( IPSText::mbstrlen( $_w ) >= $this->settings['min_search_word'] )
{
$search_term .= $_w . ' ';
}
else
{
$removedTerms[] = $_w;
}
}
}
/* Remove some formatting */
//$search_term = str_replace( array( '|', '\\', '/' ), '', $search_term );
// | is an OR operator for sphinx - don't want to block globally
$search_term = str_replace( array( '\\', '/' ), '', trim( $search_term ) );
/* got some bullean to do? */
if ( $isBoolean AND strstr( $search_term, ' ' ) AND ! strstr( $search_term, '"' ) )
{
if ( $andor == 'and' )
{
$search_term = '+' . preg_replace( '/\s+(?!-|~)/', " +", $search_term );
}
}
return array( 'search_term' => $search_term, 'removed' => $removedTerms );
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return @e void
*/
public function setDateRange( $begin, $end=0 )
{
$this->search_begin_timestamp = $begin;
$this->search_end_timestamp = $end;
}
/**
* mySQL function for adding special search conditions
*
* @access public
* @param string $column sql table column for this condition
* @param string $operator Operation to perform for this condition, ex: =, <>, IN, NOT IN
* @param mixed $value Value to check with
* @param string $comp Comparison type
* @return @e void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
$column = $this->remapColumn( $column );
if ( $column == 'app' OR ! $column )
{
return;
}
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
case 'NOT IN':
$this->whereConditions[$comp][] = "{$column} {$operator} ( {$value} )";
break;
default:
$this->whereConditions[$comp][] = "{$column} {$operator} {$value}";
break;
}
}
/**
* Remap standard columns (Apps can override )
*
* @access public
* @param string $column sql table column for this condition
* @return string column
* @return @e void
*/
public function remapColumn( $column )
{
return $column;
}
/**
* Allows you to specify multiple conditions that are chained together
*
* @access public
* @param array $conditions Array of conditions, each element has 3 keys: column, operator, value, see the setCondition function for information on each
* @param string $inner_comp Comparison operator to use inside the chain
* @param string $outer_comp Comparison operator to use outside the chain
* @return @e void
*/
public function setMultiConditions( $conditions, $inner_comp='OR', $outer_comp='AND' )
{
/* Loop through the conditions to build the statement */
$_temp = array();
foreach( $conditions as $r )
{
/* REMAP */
$r['column'] = $r['column'] == 'type_id' ? 't.forum_id' : $r['column'];
if( $r['column'] == 'app' )
{
continue;
}
switch( strtoupper( $r['operator'] ) )
{
case 'IN':
case 'NOT IN':
$_temp[] = "{$r['column']} {$r['operator']} ( {$r['value']} )";
break;
default:
$_temp[] = "{$r['column']} {$r['operator']} {$r['value']}";
break;
}
}
$this->whereConditions[$outer_comp][] = '( ' . implode( $_temp, ' ' . $inner_comp . ' ' ) . ' ) ';
}
}
+250 -250
View File
@@ -1,250 +1,250 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Global Search
* Last Updated: $Date: 2011-07-08 15:07:09 -0400 (Fri, 08 Jul 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @subpackage Core
* @link http://hatynka.in
* @version $Rev: 9189 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_format
{
/**
* Search templates to use
*
* @access protected
* @var array
*/
protected $templates = array();
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set up default wrapper */
$this->templates = array( 'group' => 'search', 'template' => 'searchResults' );
// Need to setup this manually here, won't work in the template..
$this->registry->templateStriping['searchResults'] = array( FALSE, "row1", "row2" );
}
/**
* Fetch templates to use
*
* @access public
* @return array
*/
public function fetchTemplates()
{
return $this->templates;
}
/**
* Wrapper for processResults() when called from 'Content I follow' view
*
* @param array $ids Ids
* @param array $followData Retrieve the follow meta data
* @return array
*/
public function processFollowedResults( $ids, $followData=array() )
{
/* Per app class handles this */
throw new Exception("NO_FORMAT_AVAILABLE");
}
/**
* Formats / grabs extra data for results
* Takes an array of IDS (can be IDs from anything) and returns an array of expanded data.
*
* @param array $ids Ids
* @return array
*/
public function processResults( $ids )
{
/* Per app class handles this */
throw new Exception("NO_FORMAT_AVAILABLE");
}
/**
* Reassigns fields in a generic way for results output
* DEFAULT METHOD: Just return data. This should be overriden in the apps
*
* @param array $r
* @return array
*/
public function genericizeResults( $r )
{
return $r;
}
/**
* Parse common search results
*
* @access private
* @param array $r Search result
* @return array $html Blocks of HTML
*/
public function parseAndFetchHtmlBlocks( $rows )
{
/* Forum stuff */
$sub = false;
$isVnc = false;
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$results = array();
/* loop and process */
if( is_array($rows) AND count($rows) )
{
foreach( $rows as $id => $r )
{
/* If basic search, strip the content - process only if we have content though */
if ( $r['content'] )
{
IPSText::getTextClass('bbcode')->parse_bbcode = 0;
IPSText::getTextClass('bbcode')->strip_quotes = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
$r['content'] = strip_tags( IPSText::getTextClass( 'bbcode' )->stripAllTags( $r['content'] ) );
$r['content'] = str_replace( array( '&lt;br&gt;', '&lt;br /&gt;' ), '', $r['content'] );
$r['content'] = trim( str_replace( array( "\n\n\n", "\n\n" ), "\n", str_replace( "\r", '', $r['content'] ) ) );
/* Highlight */
$r['content'] = IPSText::searchHighlight( $this->searchTruncate( $r['content'], $search_term ), $search_term );
}
/* Format title */
$r['content_title'] = IPSText::searchHighlight( $r['content_title'], $search_term );
/* Format content */
list( $html, $sub ) = $this->formatContent( $r );
$results[ $id ] = array( 'html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub, '_followData' => !empty($r['_followData']) ? $r['_followData'] : array() );
}
}
return $results;
}
/**
* Formats the forum search result for display
*
* @access public
* @param array $search_row Array of data
* @return mixed Formatted content, ready for display, or array containing a $sub section flag, and content
*/
public function formatContent( $data )
{
return array( $this->registry->output->getTemplate('search')->searchRowGenericFormat( $data ), 0 );
}
/**
* Function to trim the search result display around the the hit
*
* @access private
* @param string $haystack Full search result
* @param string $needle The search term
* @return string
*/
public function searchTruncate( $haystack, $needle )
{
/* Base on words */
$haystack = explode( " ", $haystack );
if( count( $haystack ) > 21 )
{
$_term_at = $this->searchInArray( $needle, $haystack );
if( $_term_at - 11 > 0 )
{
$begin = array_splice( $haystack, 0, $_term_at - 11 );
/* The term position will have changed now */
$_term_at = $this->searchInArray( $needle, $haystack );
}
if( $_term_at + 11 < count( $haystack ) )
{
$end = array_splice( $haystack, $_term_at + 11, count( $haystack ) );
}
}
else
{
$begin = array();
$end = array();
}
$haystack = implode( " ", $haystack );
if( is_array( $begin ) && count( $begin ) )
{
$haystack = '...' . $haystack;
}
if( is_array( $end ) && count( $end ) )
{
$haystack = $haystack . '...';
}
return $haystack;
}
/**
* Search array (array_search only finds exact instances)
*
* @access protected
* @param string "Needle"
* @param array Array of entries to search
* @return mixed Key of array, or false on failure
*/
public function searchInArray( $needle, $haystack )
{
if( !is_array( $haystack ) OR !count($haystack) OR ! $needle )
{
return false;
}
foreach( $haystack as $k => $v )
{
if( $v AND strpos( $v, $needle ) !== false )
{
return $k;
}
}
return false;
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Global Search
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 10914 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_format
{
/**
* Search templates to use
*
* @access protected
* @var array
*/
protected $templates = array();
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
/* Set up default wrapper */
$this->templates = array( 'group' => 'search', 'template' => 'searchResults' );
// Need to setup this manually here, won't work in the template..
$this->registry->templateStriping['searchResults'] = array( FALSE, "row1", "row2" );
}
/**
* Fetch templates to use
*
* @access public
* @return array
*/
public function fetchTemplates()
{
return $this->templates;
}
/**
* Wrapper for processResults() when called from 'Content I follow' view
*
* @param array $ids Ids
* @param array $followData Retrieve the follow meta data
* @return array
*/
public function processFollowedResults( $ids, $followData=array() )
{
/* Per app class handles this */
throw new Exception("NO_FORMAT_AVAILABLE");
}
/**
* Formats / grabs extra data for results
* Takes an array of IDS (can be IDs from anything) and returns an array of expanded data.
*
* @param array $ids Ids
* @return array
*/
public function processResults( $ids )
{
/* Per app class handles this */
throw new Exception("NO_FORMAT_AVAILABLE");
}
/**
* Reassigns fields in a generic way for results output
* DEFAULT METHOD: Just return data. This should be overriden in the apps
*
* @param array $r
* @return array
*/
public function genericizeResults( $r )
{
return $r;
}
/**
* Parse common search results
*
* @access private
* @param array $r Search result
* @return array $html Blocks of HTML
*/
public function parseAndFetchHtmlBlocks( $rows )
{
/* Forum stuff */
$sub = false;
$isVnc = false;
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$results = array();
/* loop and process */
if( is_array($rows) AND count($rows) )
{
foreach( $rows as $id => $r )
{
/* If basic search, strip the content - process only if we have content though */
if ( $r['content'] )
{
IPSText::getTextClass('bbcode')->parse_bbcode = 0;
IPSText::getTextClass('bbcode')->strip_quotes = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id'];
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others'];
$r['content'] = strip_tags( IPSText::getTextClass( 'bbcode' )->stripAllTags( $r['content'] ) );
$r['content'] = str_replace( array( '&lt;br&gt;', '&lt;br /&gt;' ), '', $r['content'] );
$r['content'] = trim( str_replace( array( "\n\n\n", "\n\n" ), "\n", str_replace( "\r", '', $r['content'] ) ) );
/* Highlight */
$r['content'] = IPSText::searchHighlight( $this->searchTruncate( $r['content'], $search_term ), $search_term );
}
/* Format title */
$r['content_title'] = IPSText::searchHighlight( $r['content_title'], $search_term );
/* Format content */
list( $html, $sub ) = $this->formatContent( $r );
$results[ $id ] = array( 'html' => $html, 'app' => $r['app'], 'type' => $r['type'], 'sub' => $sub, '_followData' => !empty($r['_followData']) ? $r['_followData'] : array() );
}
}
return $results;
}
/**
* Formats the forum search result for display
*
* @access public
* @param array $search_row Array of data
* @return mixed Formatted content, ready for display, or array containing a $sub section flag, and content
*/
public function formatContent( $data )
{
return array( $this->registry->output->getTemplate('search')->searchRowGenericFormat( $data ), 0 );
}
/**
* Function to trim the search result display around the the hit
*
* @access private
* @param string $haystack Full search result
* @param string $needle The search term
* @return string
*/
public function searchTruncate( $haystack, $needle )
{
/* Base on words */
$haystack = explode( " ", $haystack );
if( count( $haystack ) > 21 )
{
$_term_at = $this->searchInArray( $needle, $haystack );
if( $_term_at - 11 > 0 )
{
$begin = array_splice( $haystack, 0, $_term_at - 11 );
/* The term position will have changed now */
$_term_at = $this->searchInArray( $needle, $haystack );
}
if( $_term_at + 11 < count( $haystack ) )
{
$end = array_splice( $haystack, $_term_at + 11, count( $haystack ) );
}
}
else
{
$begin = array();
$end = array();
}
$haystack = implode( " ", $haystack );
if( is_array( $begin ) && count( $begin ) )
{
$haystack = '...' . $haystack;
}
if( is_array( $end ) && count( $end ) )
{
$haystack = $haystack . '...';
}
return $haystack;
}
/**
* Search array (array_search only finds exact instances)
*
* @access protected
* @param string "Needle"
* @param array Array of entries to search
* @return mixed Key of array, or false on failure
*/
public function searchInArray( $needle, $haystack )
{
if( !is_array( $haystack ) OR !count($haystack) OR ! $needle )
{
return false;
}
foreach( $haystack as $k => $v )
{
if( $v AND strpos( $v, $needle ) !== false )
{
return $k;
}
}
return false;
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,420 +1,423 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Admin session handler
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since Who knows...
* @version $Revision: 8644 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class adminSessions extends ips_MemberRegistry
{
/**
* Variable for session validated
*
* @access protected
* @var array
*/
protected $session_data = array();
/**
* Timeout variable
*
* @access protected
* @var int
*/
protected $_time_out_mins = 120;
/**
* Admin session
*
* @access protected
* @var string
*/
protected $_adsess = '';
/**
* Whether they are validated or not
*
* @access protected
* @var bool
*/
protected $_validated = false;
/**
* Message to display
*
* @access protected
* @var string
*/
protected $_message = '';
/**
* Authorize
*
* @access public
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
//--------------------------------------------
// Got a cookie wookey?
//--------------------------------------------
$_adsess = ipsRegistry::$request['adsess'];
$_time_out_mins = ( defined( 'IPB_ACP_SESSION_TIME_OUT' ) ) ? IPB_ACP_SESSION_TIME_OUT : 60;
//-----------------------------------------
// If the cookie doesn't match URL... use URL?
//-----------------------------------------
if ( $_adsess )
{
$this->session_type = 'url';
ipsRegistry::$request['adsess'] = $_adsess;
}
//--------------------------------------------
// Continue...
//--------------------------------------------
if ( ! ipsRegistry::$request['adsess'] )
{
//--------------------------------------------
// No URL adsess found, lets log in.
//--------------------------------------------
return $this->_response( 0, '' );
}
else
{
//--------------------------------------------
// We have a URL adsess, lets verify...
//--------------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'core_sys_cp_sessions',
'where' => "session_id='" . IPSText::md5clean( ipsRegistry::$request['adsess'] ) . "'" ) );
$this->DB->execute();
$session_data = $this->DB->fetch();
$_tab_data = unserialize( $session_data['session_app_data'] );
$_tab_data = ( is_array( $_tab_data ) ) ? $_tab_data : array();
if ( $session_data['session_id'] == "" )
{
//--------------------------------------------
// Fail-safe, no DB record found, lets log in..
//--------------------------------------------
return $this->_response( 0, '' );
}
else if ($session_data['session_member_id'] == "")
{
//--------------------------------------------
// No member ID is stored, log in!
//--------------------------------------------
return $this->_response( 0, 'session_nomemberid' );
}
else
{
//--------------------------------------------
// Key is good, check the member details
//--------------------------------------------
$this->DB->build( array(
'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => "member_id=".intval($session_data['session_member_id']),
'add_join' => array( 0 => array( 'select' => 'g.*',
'from' => array( 'groups' => 'g' ),
'where' => 'm.member_group_id=g.g_id',
'type' => 'left'
),
1 => array( 'select' => 's.*',
'from' => array( 'core_sys_login' => 's' ),
'where' => 's.sys_login_id = m.member_id',
'type' => 'left'
)
)
) );
$this->DB->execute();
self::$data_store = $this->DB->fetch();
self::$data_store = self::instance()->setUpSecondaryGroups( self::$data_store );
//--------------------------------------------
// Get perms
//--------------------------------------------
if ( self::$data_store['member_id'] == "" )
{
//--------------------------------------------
// Ut-oh, no such member, log in!
//--------------------------------------------
return $this->_response( 0, 'session_invalidmid' );
}
else
{
//--------------------------------------------
// Member found, check passy
//--------------------------------------------
//if ( $session_data['session_member_login_key'] != self::$data_store['member_login_key'] )
//{
// //--------------------------------------------
// // Passys don't match..
// //--------------------------------------------
//
// return $this->_response( 0, 'Session member password mismatch' );
//}
//else
//{
//--------------------------------------------
// Do we have admin access?
//--------------------------------------------
if (self::$data_store['g_access_cp'] != 1)
{
return $this->_response( 0, 'session_noaccess' );
}
else
{
$this->_validated = TRUE;
}
//}
}
}
}
//--------------------------------------------
// If we're here, we're valid...
//--------------------------------------------
if ( $this->_validated === TRUE )
{
if ( $session_data['session_running_time'] < ( time() - $_time_out_mins * 60 ) )
{
self::$data_store = array();
self::setMember( 0 );
$this->_validated = FALSE;
return $this->_response( 0, 'session_timeout' );
}
//------------------------------
// Are we checking IP's?
//------------------------------
else if ( IPB_ACP_IP_MATCH )
{
$first_ip = preg_replace( "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3", $session_data['session_ip_address'] );
$second_ip = preg_replace( "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3", self::instance()->ip_address );
if ( $first_ip != $second_ip )
{
self::$data_store = array();
self::setMember( 0 );
$this->_validated = FALSE;
return $this->_response( 0, 'session_mismatchip' );
}
}
self::setMember( self::$data_store['member_id'] );
//-----------------------------------------
// Fix up secondary groups
//-----------------------------------------
if ( self::$data_store['mgroup_others'] )
{
$groups_id = explode( ',', self::$data_store['mgroup_others'] );
$masks = array();
$cache = ipsRegistry::cache()->getCache('group_cache');
if ( count( $groups_id ) )
{
foreach( $groups_id as $pid )
{
if ( empty($cache[ $pid ]['g_id']) )
{
continue;
}
//-----------------------------------------
// Got masks?
//-----------------------------------------
if ( $cache[ $pid ]['g_perm_id'] )
{
self::$data_store['g_perm_id'] .= ',' . $cache[ $pid ]['g_perm_id'];
}
}
}
}
//-----------------------------------------
// Current Location, used for online list
//-----------------------------------------
$module = ipsRegistry::$request['module'] != 'ajax' ? ipsRegistry::$request['module'] : $session_data['session_location'];
$location = $session_data['session_url'];
if ( ( IPS_APP_COMPONENT ) && ipsRegistry::$request['module'] != 'ajax' )
{
$location = str_ireplace( "login=yes" , "" , ipsRegistry::$settings['query_string_safe'] );
$location = ltrim( $location , '?' );
$location = preg_replace( "!adsess=(\w){32}!" , "" , $location );
$location = preg_replace( "!&mshow=(.+?)*!i" , "" , $location );
$location = preg_replace( "!&st=(.+?)*!i" , "" , $location );
$location = preg_replace( "!&messageinabottleacp=(.+?)*!i" , "" , $location );
}
/* Compare user-agent stuff */
$session_data['_session_app_data'] = unserialize( $session_data['session_app_data'] );
if ( is_array( $session_data['_session_app_data'] ) AND $session_data['_session_app_data']['uagent_key'] )
{
if ( $session_data['_session_app_data']['uagent_raw'] != self::instance()->user_agent )
{
$session_data['_session_app_data'] = self::_processUserAgent();
$session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
}
}
else
{
$session_data['_session_app_data'] = self::_processUserAgent();
$session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
}
//-----------------------------------------
// Done...
//-----------------------------------------
$this->DB->update( 'core_sys_cp_sessions',
array( 'session_running_time' => time(),
'session_location' => $module,
'session_url' => $location,
'session_app_data' => serialize( $session_data['_session_app_data'] ),
'session_member_name' => self::$data_store['members_display_name'],
),
'session_member_id='.intval(self::$data_store['member_id'])." and session_id='".ipsRegistry::$request['adsess']."'" );
return $this->_response( 1, '', $session_data['_session_app_data'] );
}
}
/**
* Get the validation status
*
* @access public
* @return bool
*/
public function getStatus()
{
return $this->_validated;
}
/**
* Get the validation message
*
* @access public
* @return string
*/
public function getMessage()
{
return !empty($this->registry->class_localization->words[ $this->_message ]) ? $this->registry->class_localization->words[ $this->_message ] : $this->_message;
}
/**
* Grab the user agent from the DB if required
*
* @access protected
* @return array Array of user agent info from the DB
*/
protected function _processUserAgent()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$uAgent = array( 'uagent_key' => '__NONE__',
'uagent_version' => 0,
'uagent_name' => '',
'uagent_type' => '',
'uagent_bypass' => 0 );
//-----------------------------------------
// Get useragent stuff
//-----------------------------------------
if ( ! $this->registry->isClassLoaded( 'userAgentFunctions' ) )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/useragents/userAgentFunctions.php', 'userAgentFunctions' );
$this->registry->setClass( 'userAgentFunctions', new $classToLoad( $this->registry ) );
}
$uAgent = $this->registry->getClass( 'userAgentFunctions' )->findUserAgentID( self::instance()->user_agent );
if ( $uAgent['uagent_key'] === NULL )
{
$uAgent = array( 'uagent_key' => '__NONE__',
'uagent_version' => 0,
'uagent_name' => '',
'uagent_type' => '',
'uagent_bypass' => 0 );
}
return $uAgent;
}
/**
* Set the response
*
* @access protected
* @param bool Authenticated or not
* @param string Message
* @param array Array of user agent data
* @return @e void
*/
protected function _response( $validated, $message, $userAgentData=array() )
{
$this->_validated = $validated;
$this->_message = $message;
$this->session_data = $userAgentData;
return;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Admin session handler
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since Who knows...
* @version $Revision: 10914 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class adminSessions extends ips_MemberRegistry
{
/**
* Variable for session validated
*
* @access protected
* @var array
*/
protected $session_data = array();
/**
* Timeout variable
*
* @access protected
* @var int
*/
protected $_time_out_mins = 120;
/**
* Admin session
*
* @access protected
* @var string
*/
protected $_adsess = '';
/**
* Whether they are validated or not
*
* @access protected
* @var bool
*/
protected $_validated = false;
/**
* Message to display
*
* @access protected
* @var string
*/
protected $_message = '';
/**
* Authorize
*
* @access public
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
//--------------------------------------------
// Got a cookie wookey?
//--------------------------------------------
$_adsess = ipsRegistry::$request['adsess'];
$_time_out_mins = ( defined( 'IPB_ACP_SESSION_TIME_OUT' ) ) ? IPB_ACP_SESSION_TIME_OUT : 60;
//-----------------------------------------
// If the cookie doesn't match URL... use URL?
//-----------------------------------------
if ( $_adsess )
{
$this->session_type = 'url';
ipsRegistry::$request['adsess'] = $_adsess;
}
//--------------------------------------------
// Continue...
//--------------------------------------------
if ( ! ipsRegistry::$request['adsess'] )
{
//--------------------------------------------
// No URL adsess found, lets log in.
//--------------------------------------------
return $this->_response( 0, '' );
}
else
{
//--------------------------------------------
// We have a URL adsess, lets verify...
//--------------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'core_sys_cp_sessions',
'where' => "session_id='" . IPSText::md5clean( ipsRegistry::$request['adsess'] ) . "'" ) );
$this->DB->execute();
$session_data = $this->DB->fetch();
$_tab_data = unserialize( $session_data['session_app_data'] );
$_tab_data = ( is_array( $_tab_data ) ) ? $_tab_data : array();
if ( $session_data['session_id'] == "" )
{
//--------------------------------------------
// Fail-safe, no DB record found, lets log in..
//--------------------------------------------
return $this->_response( 0, '' );
}
else if ($session_data['session_member_id'] == "")
{
//--------------------------------------------
// No member ID is stored, log in!
//--------------------------------------------
return $this->_response( 0, 'session_nomemberid' );
}
else
{
//--------------------------------------------
// Key is good, check the member details
//--------------------------------------------
$this->DB->build( array(
'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => "member_id=".intval($session_data['session_member_id']),
'add_join' => array( 0 => array( 'select' => 'g.*',
'from' => array( 'groups' => 'g' ),
'where' => 'm.member_group_id=g.g_id',
'type' => 'left'
),
1 => array( 'select' => 's.*',
'from' => array( 'core_sys_login' => 's' ),
'where' => 's.sys_login_id = m.member_id',
'type' => 'left'
)
)
) );
$this->DB->execute();
self::$data_store = $this->DB->fetch();
self::$data_store = self::instance()->setUpSecondaryGroups( self::$data_store );
//--------------------------------------------
// Get perms
//--------------------------------------------
if ( self::$data_store['member_id'] == "" )
{
//--------------------------------------------
// Ut-oh, no such member, log in!
//--------------------------------------------
return $this->_response( 0, 'session_invalidmid' );
}
else
{
//--------------------------------------------
// Member found, check passy
//--------------------------------------------
//if ( $session_data['session_member_login_key'] != self::$data_store['member_login_key'] )
//{
// //--------------------------------------------
// // Passys don't match..
// //--------------------------------------------
//
// return $this->_response( 0, 'Session member password mismatch' );
//}
//else
//{
//--------------------------------------------
// Do we have admin access?
//--------------------------------------------
if (self::$data_store['g_access_cp'] != 1)
{
return $this->_response( 0, 'session_noaccess' );
}
else
{
$this->_validated = TRUE;
}
//}
}
}
}
//--------------------------------------------
// If we're here, we're valid...
//--------------------------------------------
if ( $this->_validated === TRUE )
{
if ( $session_data['session_running_time'] < ( time() - $_time_out_mins * 60 ) )
{
self::$data_store = array();
self::setMember( 0 );
$this->_validated = FALSE;
return $this->_response( 0, 'session_timeout' );
}
//------------------------------
// Are we checking IP's?
//------------------------------
else if ( IPB_ACP_IP_MATCH )
{
if (
$session_data['session_ip_address'] != self::instance()->ip_address
or
( !IPSLib::validateIPv4( $session_data['session_ip_address'] ) and !IPSLib::validateIPv6( $session_data['session_ip_address'] ) )
or
( !IPSLib::validateIPv4( self::instance()->ip_address ) and !IPSLib::validateIPv6( self::instance()->ip_address ) )
)
{
self::$data_store = array();
self::setMember( 0 );
$this->_validated = FALSE;
return $this->_response( 0, 'session_mismatchip' );
}
}
self::setMember( self::$data_store['member_id'] );
//-----------------------------------------
// Fix up secondary groups
//-----------------------------------------
if ( self::$data_store['mgroup_others'] )
{
$groups_id = explode( ',', self::$data_store['mgroup_others'] );
$masks = array();
$cache = ipsRegistry::cache()->getCache('group_cache');
if ( count( $groups_id ) )
{
foreach( $groups_id as $pid )
{
if ( empty($cache[ $pid ]['g_id']) )
{
continue;
}
//-----------------------------------------
// Got masks?
//-----------------------------------------
if ( $cache[ $pid ]['g_perm_id'] )
{
self::$data_store['g_perm_id'] .= ',' . $cache[ $pid ]['g_perm_id'];
}
}
}
}
//-----------------------------------------
// Current Location, used for online list
//-----------------------------------------
$module = ipsRegistry::$request['module'] != 'ajax' ? ipsRegistry::$request['module'] : $session_data['session_location'];
$location = $session_data['session_url'];
if ( ( IPS_APP_COMPONENT ) && ipsRegistry::$request['module'] != 'ajax' )
{
$location = str_ireplace( "login=yes" , "" , ipsRegistry::$settings['query_string_safe'] );
$location = ltrim( $location , '?' );
$location = preg_replace( "!adsess=(\w){32}!" , "" , $location );
$location = preg_replace( "!&mshow=(.+?)*!i" , "" , $location );
$location = preg_replace( "!&st=(.+?)*!i" , "" , $location );
$location = preg_replace( "!&messageinabottleacp=(.+?)*!i" , "" , $location );
}
/* Compare user-agent stuff */
$session_data['_session_app_data'] = unserialize( $session_data['session_app_data'] );
if ( is_array( $session_data['_session_app_data'] ) AND $session_data['_session_app_data']['uagent_key'] )
{
if ( $session_data['_session_app_data']['uagent_raw'] != self::instance()->user_agent )
{
$session_data['_session_app_data'] = self::_processUserAgent();
$session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
}
}
else
{
$session_data['_session_app_data'] = self::_processUserAgent();
$session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
}
//-----------------------------------------
// Done...
//-----------------------------------------
$this->DB->update( 'core_sys_cp_sessions',
array( 'session_running_time' => time(),
'session_location' => $module,
'session_url' => $location,
'session_app_data' => serialize( $session_data['_session_app_data'] ),
'session_member_name' => self::$data_store['members_display_name'],
),
'session_member_id='.intval(self::$data_store['member_id'])." and session_id='".ipsRegistry::$request['adsess']."'" );
return $this->_response( 1, '', $session_data['_session_app_data'] );
}
}
/**
* Get the validation status
*
* @access public
* @return bool
*/
public function getStatus()
{
return $this->_validated;
}
/**
* Get the validation message
*
* @access public
* @return string
*/
public function getMessage()
{
return !empty($this->registry->class_localization->words[ $this->_message ]) ? $this->registry->class_localization->words[ $this->_message ] : $this->_message;
}
/**
* Grab the user agent from the DB if required
*
* @access protected
* @return array Array of user agent info from the DB
*/
protected function _processUserAgent()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$uAgent = array( 'uagent_key' => '__NONE__',
'uagent_version' => 0,
'uagent_name' => '',
'uagent_type' => '',
'uagent_bypass' => 0 );
//-----------------------------------------
// Get useragent stuff
//-----------------------------------------
if ( ! $this->registry->isClassLoaded( 'userAgentFunctions' ) )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/useragents/userAgentFunctions.php', 'userAgentFunctions' );
$this->registry->setClass( 'userAgentFunctions', new $classToLoad( $this->registry ) );
}
$uAgent = $this->registry->getClass( 'userAgentFunctions' )->findUserAgentID( self::instance()->user_agent );
if ( $uAgent['uagent_key'] === NULL )
{
$uAgent = array( 'uagent_key' => '__NONE__',
'uagent_version' => 0,
'uagent_name' => '',
'uagent_type' => '',
'uagent_bypass' => 0 );
}
return $uAgent;
}
/**
* Set the response
*
* @access protected
* @param bool Authenticated or not
* @param string Message
* @param array Array of user agent data
* @return @e void
*/
protected function _response( $validated, $message, $userAgentData=array() )
{
$this->_validated = $validated;
$this->_message = $message;
$this->session_data = $userAgentData;
return;
}
}
+416 -262
View File
@@ -1,263 +1,417 @@
<?php
/**
* @file api.php Provides global methods to retrieve active users from the sessions table
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: This is NULLED!
* $Author: ips_terabyte $
* @since Friday 12th November 2010 16:58
* $LastChangedDate: 2011-08-26 11:38:16 -0400 (Fri, 26 Aug 2011) $
* @version v3.2.3
* $Revision: 9420 $
*/
/**
*
* @class session_api
* @brief Provides global methods to retrieve active users from the sessions table
*
*/
class session_api
{
/**
* Registry Object Shortcuts
*
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**
* Constructor
*
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Returns a list (with buildProfilePhoto set) of users in an application
*
* @param string $app Application folder/key
* @param array $options Array of options to add/override checks for the query
* @return @e array Array of found sessions (members, guests, bots, anons)
*
* <b>Filters:</b>
* - cutoff: Specify a different cutoff time rather than using the default setting
* - addJoins: Add more joins for the query
* - addWhere: Add more checks for the 'where' part of the query (everything is joined with ' AND ')
* - overrideWhere: Specify manually the 'where' part of the query, the query must be already compiled
*
* <b>Example Usage:</b>
* @code
* $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90 ) );
* $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90, 'addJoins' => array( ... ), 'addWhere' => array( ... ) ) );
* $onlineUsers = $this->getUsersIn( 'forums', array( 'overrideWhere' => "s.current_appcomponent='forums' AND (s.running_time > TIME_A OR s.running_time < TIME_B)" ) );
* @endcode
*/
public function getUsersIn( $app, $options=array() )
{
/* Init vars and check options */
$return = array( 'stats' => array( 'total' => 0,
'members' => 0,
'guests' => 0,
'bots' => 0,
'anon' => 0 ),
'rows' => array( 'members' => array(),
'bots' => array(),
'guests' => array(),
'anon' => array() ),
'names' => array()
);
$cutoff = empty($options['cutoff']) ? $this->settings['au_cutoff'] : $options['cutoff'];
$limit = time() - ( $cutoff * 60 );
$rows = array();
$NOWJIM = IPS_UNIX_TIME_NOW;
$cached = array();
/* Sort joins */
$_joins = array( array( 'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=s.member_id',
'type' => 'left' ) );
if ( isset($options['addJoins']) && is_array($options['addJoins']) && count($options['addJoins']) )
{
$where = array_merge( $_joins, $options['addJoins'] );
}
/* Sort where.. override? */
if ( !empty($options['overrideWhere']) && is_string($options['overrideWhere']) )
{
$where = $options['overrideWhere'];
}
else
{
/* Normal where */
$where = array( "s.current_appcomponent='" . $app . "'", "s.running_time > " . $limit );
if ( isset($options['addWhere']) && is_array($options['addWhere']) && count($options['addWhere']) )
{
$where = array_merge( $where, $options['addWhere'] );
}
$where = implode( ' AND ', $where );
}
/* We're a member too? */
if ( $this->memberData['member_id'] )
{
$rows[ $NOWJIM . '.' . $this->memberData['member_id'] ] = array_merge( $this->memberData,
array( 'id' => $this->member->session_id,
'login_type' => substr($this->memberData['login_anonymous'],0, 1),
'running_time' => $NOWJIM,
'member_name' => $this->memberData['members_display_name'],
'member_group' => $this->memberData['member_group_id'],
'seo_name' => $this->memberData['members_seo_name'] )
);
}
/* Dee bee */
$this->DB->build( array( 'select' => 's.*, s.id as row_session_id',
'from' => array( 'sessions' => 's' ),
'where' => $where,
'add_join' => $_joins ) );
$this->DB->execute();
while( $session = $this->DB->fetch() )
{
if ( ! empty( $session['member_id'] ) AND $session['member_id'] == $this->memberData['member_id'] )
{
continue;
}
$session['id'] = $session['row_session_id'];
$rows[ $session['running_time'] . '.' . $session['id'] ] = $session;
}
/* No rows? */
if ( ! count( $rows ) )
{
return $return;
}
krsort( $rows );
/* Process them */
$filename = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
if ( is_file( $filename ) )
{
$classToLoad = IPSLib::loadLibrary( $filename, 'publicSessions__' . $app, $app );
$loader = new $classToLoad();
if ( method_exists( $loader, 'parseOnlineEntries' ) )
{
$rows = $loader->parseOnlineEntries( $rows );
}
}
/* No rows? */
if ( ! count( $rows ) )
{
return $return;
}
/* Sort through */
foreach( $rows as $id => $result )
{
$last_date = $this->registry->getClass('class_localization')->getTime( $result['running_time'] );
/* ROBOT - or DODOT! */
if ( strstr( $result['id'], '_session' ) )
{
$botname = preg_replace( '/^(.+?)=/', "\\1", $result['id'] );
if ( ! $cached[ $result['member_name'] ] )
{
$result = IPSMember::buildProfilePhoto( $result );
$result['parsedMemberName'] = $result['member_name'];
$return['rows']['bots'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
$cached[ $result['member_name'] ] = 1;
}
$return['stats']['bots']++;
}
/* Guest */
else if ( ! $result['member_id'] )
{
$result = IPSMember::buildProfilePhoto( 0 );
$result['parsedMemberName'] = $this->lang->words['global_guestname'];
$return['rows']['guests'][ $result['id'] ] = $result;
$return['stats']['guests']++;
}
/* Member */
else
{
if ( empty( $cached[ $result['member_id'] ] ) )
{
$cached[ $result['member_id'] ] = 1;
$result = IPSMember::buildProfilePhoto( $result );
$result['parsedMemberName'] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'] );
if ( $result['login_type'] )
{
if ( $this->memberData['g_access_cp'] )
{
$result['parsedMemberName'] = IPSMember::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$return['rows']['anon'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
}
$return['stats']['anon']++;
}
else
{
$result['parsedMemberName'] = IPSMember::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$return['rows']['members'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
$return['stats']['members']++;
}
}
}
}
$return['stats']['total'] = intval( $return['stats']['bots'] ) + intval( $return['stats']['guests'] ) + intval( $return['stats']['anon'] ) + intval( $return['stats']['members'] );
return $return;
}
<?php
/**
* @file api.php Provides global methods to retrieve active users from the sessions table
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: bfarber $
* @since Friday 12th November 2010 16:58
* $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* @version v3.3.4
* $Revision: 10914 $
*/
/**
*
* @class session_api
* @brief Provides global methods to retrieve active users from the sessions table
*
*/
class session_api
{
/**
* Registry Object Shortcuts
*
* @var $registry
* @var $DB
* @var $settings
* @var $request
* @var $lang
* @var $member
* @var $memberData
* @var $cache
* @var $caches
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
private $_sClass = null;
const NO_AUTO_SESSION_PARSING = true;
/**
* Constructor
*
* @param object $registry Registry object
* @return @e void
*/
public function __construct( ipsRegistry $registry )
{
/* Make object */
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Returns a list (with buildProfilePhoto set) of users in an application
*
* @param string $app Application folder/key
* @param array $options Array of options to add/override checks for the query
* @return @e array Array of found sessions (members, guests, bots, anons)
*
* <b>Filters:</b>
* - cutoff: Specify a different cutoff time rather than using the default setting
* - addJoins: Add more joins for the query
* - addWhere: Add more checks for the 'where' part of the query (everything is joined with ' AND ')
* - overrideWhere: Specify manually the 'where' part of the query, the query must be already compiled
* - overrideGroup: if set to true the check against the 'gbw_view_online_lists' group setting is skipped
* - skipParsing: If set to true the parseOnlineEntries from coreExtensions is NOT executed
* - includeErrors: If set to true the in_error=1 lines are loaded as well from the table
* - excludeViewer: If set to true skips loading the row for the current session_id, it is required to load the current member viewing the page as sessions table is not updated at this point yet but only on destruct
*
* <b>Example Usage:</b>
* @code
* $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90 ) );
* $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90, 'addJoins' => array( ... ), 'addWhere' => array( ... ) ) );
* $onlineUsers = $this->getUsersIn( 'forums', array( 'overrideWhere' => "s.current_appcomponent='forums' AND (s.running_time > TIME_A OR s.running_time < TIME_B)" ) );
* @endcode
*/
public function getUsersIn( $app, $options=array() )
{
/* App we're checking is not even installed? */
if ( ! IPSLib::appIsInstalled( $app, false ) )
{
return array();
}
/* Can't view online lists? */
if ( empty($options['overrideGroup']) && ! $this->memberData['gbw_view_online_lists'] )
{
return array();
}
/* Init vars and check options */
$return = array( 'stats' => array( 'total' => 0,
'members' => 0,
'guests' => 0,
'bots' => 0,
'anon' => 0 ),
'rows' => array( 'members' => array(),
'bots' => array(),
'guests' => array(),
'anon' => array() ),
'names' => array()
);
$cutoff = empty($options['cutoff']) ? $this->settings['au_cutoff'] : $options['cutoff'];
$limit = time() - ( $cutoff * 60 );
$rows = array();
$NOWJIM = IPS_UNIX_TIME_NOW;
$cached = array();
/* Sort joins */
$_joins = array( array( 'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=s.member_id',
'type' => 'left' ) );
if ( isset($options['addJoins']) && is_array($options['addJoins']) && count($options['addJoins']) )
{
$_joins = array_merge( $_joins, $options['addJoins'] );
}
/* Sort where.. override? */
if ( !empty($options['overrideWhere']) && is_string($options['overrideWhere']) )
{
$where = $options['overrideWhere'];
}
else
{
/* Normal where */
$where = array( "s.current_appcomponent='" . $this->DB->addSlashes( $app ) . "'", 's.running_time > ' . $limit );
/* Load error rows? */
if ( empty($options['includeErrors']) )
{
$where[] = 's.in_error=0';
}
/* Add more where parts */
if ( isset($options['addWhere']) && is_array($options['addWhere']) && count($options['addWhere']) )
{
$where = array_merge( $where, $options['addWhere'] );
}
$where = implode( ' AND ', $where );
}
/* We're a viewer too? Get our session separately */
$_extraWhere = empty($options['excludeViewer']) ? "s.id='{$this->member->session_id}' OR " : '';
/* Dee bee */
$this->DB->build( array( 'select' => 's.*, s.id as row_session_id',
'from' => array( 'sessions' => 's' ),
'where' => "{$_extraWhere}({$where})",
'add_join' => $_joins ) );
$this->DB->execute();
while( $session = $this->DB->fetch() )
{
/* Reset for possible bad joins */
$session['id'] = $session['row_session_id'];
/* Update our own session properly? */
if ( $session['id'] == $this->member->session_id )
{
$session = array_merge( $session, $this->member->sessionClass()->returnCurrentSession() );
}
$rows[ $session['running_time'] . '.' . $session['id'] ] = $session;
}
/* No rows? */
if ( ! count( $rows ) )
{
return $return;
}
krsort( $rows );
/* Are we parsing online entries or want only the names */
if ( empty( $options['skipParsing'] ) )
{
/* Process them */
$filename = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
if ( is_file( $filename ) )
{
$classToLoad = IPSLib::loadLibrary( $filename, 'publicSessions__' . $app, $app );
$loader = new $classToLoad();
if ( method_exists( $loader, 'parseOnlineEntries' ) )
{
$rows = $loader->parseOnlineEntries( $rows );
}
}
/* No rows? */
if ( ! count( $rows ) )
{
return $return;
}
}
/* Sort through */
foreach( $rows as $id => $result )
{
$last_date = $this->registry->getClass('class_localization')->getTime( $result['running_time'] );
/* ROBOT - or DODOT! */
if ( strstr( $result['id'], '_session' ) )
{
$botname = preg_replace( '/^(.+?)=/', "\\1", $result['id'] );
if ( ! $cached[ 'srch_' . $result['member_name'] ] )
{
$result = IPSMember::buildProfilePhoto( $result );
$result['parsedMemberName'] = $result['member_name'];
$return['rows']['bots'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
$cached[ 'srch_' . $result['member_name'] ]['count'] = 1;
}
else
{
$cached[ 'srch_' . $result['member_name'] ]['count']++;
}
$return['stats']['bots']++;
}
/* Guest */
else if ( ! $result['member_id'] )
{
$result = IPSMember::buildProfilePhoto( 0 );
$result['parsedMemberName'] = $this->lang->words['global_guestname'];
$return['rows']['guests'][ $result['id'] ] = $result;
$return['stats']['guests']++;
}
/* Member */
else
{
if ( empty( $cached[ $result['member_id'] ] ) )
{
$cached[ $result['member_id'] ] = 1;
$result = IPSMember::buildProfilePhoto( $result );
$result['parsedMemberName'] = IPSMember::makeNameFormatted( $result['member_name'], $result['member_group'] );
/* Reset login type in case the board/group setting got changed */
$result['login_type'] = IPSMember::isLoggedInAnon( array( 'login_anonymous' => $result['login_type'] ), $result['member_group_id'] );
if ( $result['login_type'] )
{
if ( $this->memberData['g_access_cp'] || ( $this->memberData['member_id'] == $result['member_id'] ) )
{
$result['parsedMemberName'] = IPSMember::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$result['parsedMemberName'] .= '*'; # Add anonymous asterisk
$return['rows']['anon'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
}
$return['stats']['anon']++;
}
else
{
$result['parsedMemberName'] = IPSMember::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$return['rows']['members'][ $result['id'] ] = $result;
$return['names'][ $result['id'] ] = $result['parsedMemberName'];
$return['stats']['members']++;
}
}
}
}
/* Process bots */
foreach( $cached as $name => $val )
{
if ( $val['count'] && substr( $name, 0, 5 ) == 'srch_' )
{
foreach( $return['rows']['bots'] as $row )
{
if ( $row['parsedMemberName'] == substr( $name, 5 ) )
{
$return['rows']['bots'][ $row['id'] ]['parsedMemberName'] .= ' (' . $val['count'] . ')';
$return['rows']['bots'][ $row['id'] ]['member_name'] = $return['rows']['bots'][ $row['id'] ]['parsedMemberName'];
$return['names'][ $row['id'] ] = $return['rows']['bots'][ $row['id'] ]['parsedMemberName'];
break;
}
}
}
}
$return['stats']['total'] = intval( $return['stats']['bots'] ) + intval( $return['stats']['guests'] ) + intval( $return['stats']['anon'] ) + intval( $return['stats']['members'] );
return $return;
}
/**
* Fetch session by member id
* @param int Member Id
* @return array session data
*/
public function getSessionByMemberId( $memberId )
{
$_session = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'sessions',
'where' => "member_id=" . intval( $memberId ) ) );
if ( $_session['id'] )
{
/* Test for browser.... */
if ( $this->settings['match_browser'])
{
if ( $_session['browser'] != substr( $this->member->user_agent, 0, 200 ) )
{
return false;
}
}
/* Test for IP Address... */
if ( $this->settings['match_ipaddress'] )
{
if ( $_session['ip_address'] != $this->member->ip_address )
{
return false;
}
}
return $_session;
}
return false;
}
/**
* Log user in remotely.
* @param array Array of member data (member_id, etc) or Id
*/
public function logGuestInAsMember( $member )
{
if ( is_numeric( $member ) )
{
$member = IPSMember::load( $member );
}
/* Check for existing session */
$ip = ipsRegistry::member()->ip_address;
$_session = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'sessions',
'where' => "ip_address='{$ip}'" ) );
if ( !$_session['id'] or !$_session['member_id'] )
{
$this->_getSessionClass()->convertGuestToMember( $member, $member );
}
}
/**
* Load session class if not loaded
*/
protected function _getSessionClass()
{
if ( ! is_object( $this->_sClass ) )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/session/publicSessions.php', 'publicSessions' );
/**
* Support for extending the session class
*/
if ( is_file( IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php" ) )
{
$classToLoadA = IPSLib::loadLibrary( IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php", 'ssoPublicSessions' );
/**
* Does the ssoPublicSessions class exist?
*/
if( class_exists( $classToLoadA ) )
{
$parent = get_parent_class( $classToLoadA );
/**
* Is it a child of publicSessions
*/
if ( $parent == $classToLoad )
{
$this->_sClass = new $classToLoadA( self::NO_AUTO_SESSION_PARSING );
}
else
{
$this->_sClass = new $classToLoad( self::NO_AUTO_SESSION_PARSING );
}
}
}
else
{
$this->_sClass = new $classToLoad( self::NO_AUTO_SESSION_PARSING );
}
}
return $this->_sClass;
}
}
@@ -1,75 +1,75 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* This class overrides parent publicSessions to prevent construct being called
* It doesn't do anything else...
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
* </pre>
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @subpackage IP.Converge
* @link http://hatynka.in
* @since 22nd May 2008 11:15 AM
* @version $Revision: 8644 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class convergeSessions extends publicSessions
{
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function __construct( $registry )
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->_member = self::instance();
$this->_memberData =& self::instance()->fetchMemberData();
$this->_userAgent = substr( $this->_member->user_agent, 0, 200 );
//-----------------------------------------
// Fix up app / section / module
//-----------------------------------------
$this->current_appcomponent = IPS_APP_COMPONENT;
$this->current_module = IPSText::alphanumericalClean( $this->request['module'] );
$this->current_section = IPSText::alphanumericalClean( $this->request['section'] );
$this->settings['session_expiration'] = ( $this->settings['session_expiration'] ) ? $this->settings['session_expiration'] : 60;
}
/**
* Create a member session
*
* @access public
* @return string Session id
*/
public function createMemberSession()
{
parent::_createMemberSession();
return $this->session_data['id'];
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* This class overrides parent publicSessions to prevent construct being called
* It doesn't do anything else...
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage IP.Converge
* @link http://www.invisionpower.com
* @since 22nd May 2008 11:15 AM
* @version $Revision: 10914 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class convergeSessions extends publicSessions
{
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return @e void
*/
public function __construct( $registry )
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->_member = self::instance();
$this->_memberData =& self::instance()->fetchMemberData();
$this->_userAgent = substr( $this->_member->user_agent, 0, 200 );
//-----------------------------------------
// Fix up app / section / module
//-----------------------------------------
$this->current_appcomponent = IPS_APP_COMPONENT;
$this->current_module = IPSText::alphanumericalClean( $this->request['module'] );
$this->current_section = IPSText::alphanumericalClean( $this->request['section'] );
$this->settings['session_expiration'] = ( $this->settings['session_expiration'] ) ? $this->settings['session_expiration'] : 60;
}
/**
* Create a member session
*
* @access public
* @return string Session id
*/
public function createMemberSession()
{
parent::_createMemberSession();
return $this->session_data['id'];
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -3,18 +3,18 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* IP.Board v3.3.4
* Sample SSO Class
* Last Updated: $Date: 2010-12-17 08:01:38 -0500 (Fri, 17 Dec 2010) $
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
* </pre>
*
* @author $Author: ips_terabyte $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://hatynka.in
* @link http://www.invisionpower.com
* @since 22nd Septmeber 2009
* @version $Revision: 7445 $
* @version $Revision: 10914 $
*
*/
@@ -0,0 +1,65 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Sample Mobile App SSO Class
* Last Updated: $Date: 2012-05-10 21:10:13 +0100 (Thu, 10 May 2012) $
* </pre>
*
* @author $Author: Matt $
* @copyright (c) 2001 - 2012 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 22nd Septmeber 2009
* @version $Revision: 10721 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class ssoMobileAppLogIn
{
/**
* Constructor
*
* @access public
* @param object ipsRegistry object
*/
public function __construct( ipsRegistry $registry )
{
}
/**
* authenticate
* Used to authenticate a user from the mobile app to your SSO framework
*
* @access public
* @param string $username Username sent from app
* @param string $password Password sent from app (plain text version)
*/
public function authenticate( $username, $password )
{
/*
You are expected to authenticate the user against your SSO framework.
The return value is an array:
'code' is a string of:
SUCCESS - User authenticated
FAILED - User did not authenticate
'memberId' is an INT of the IPB member ID of the user who authenticated
*/
/* Default value */
return array( 'code' => 'FAILED',
'memberId' => 0 );
}
}
@@ -1,10 +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.invisionpower.com">IP.Board</a>
</body>
<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.invisionpower.com">IP.Board</a>
</body>
</html>
Loaded 100 of 2206 files, more files were not shown because too many files have changed in this diff. Show more