Version 3.1.4

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

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Advertisements
* </pre>
*
* @author $Author: josh $
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 17th February 2010
* @version $Revision: 6017 $
*/
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 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 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 ];
}
}
+485 -107
View File
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* BBCode parsing core - common methods
* Last Updated: $Date: 2009-12-07 21:57:46 -0500 (Mon, 07 Dec 2009) $
* Last Updated: $Date: 2010-10-12 18:11:21 -0400 (Tue, 12 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5529 $
* @version $Revision: 6965 $
*
* Basic usage examples
* <code>
@@ -181,6 +183,14 @@ class class_bbcode_core
* @var integer
*/
protected $emoticon_count = 0;
/**
* Array of emoticon alt tags
*
* @access protected
* @var array
*/
protected $emoticon_alts = array();
/**
* Registry object
@@ -342,6 +352,12 @@ class class_bbcode_core
foreach( $this->cache->getCache('bbcode') as $bbcode )
{
/* Cheat a bit */
if ( $bbcode['bbcode_tag'] == 'code' OR $bbcode['bbcode_tag'] == 'acronym' OR $bbcode['bbcode_tag'] == 'img' )
{
$bbcode['bbcode_no_auto_url_parse'] = 1;
}
//-----------------------------------------
// BBcode allowed in this section?
//-----------------------------------------
@@ -370,7 +386,7 @@ class class_bbcode_core
// Store into the array
//-----------------------------------------
$this->_bbcodes[ $bbcode['bbcode_parse'] == 1 ? 'db' : 'display' ][ $bbcode['bbcode_tag'] ] = $bbcode;
$this->_bbcodes['display'][ $bbcode['bbcode_tag'] ] = $bbcode;
}
}
@@ -425,7 +441,7 @@ class class_bbcode_core
* @param boolean Fix script HTML tags
* @return string "Cleaned" text
*/
public function checkXss( $txt='', $fixScript=false )
public function checkXss( $txt='', $fixScript=false, $tag='' )
{
//-----------------------------------------
// Opening script tags...
@@ -434,10 +450,101 @@ class class_bbcode_core
if ( $fixScript )
{
$txt = preg_replace( "#<(\s+?)?s(\s+?)?c(\s+?)?r(\s+?)?i(\s+?)?p(\s+?)?t#is" , "&lt;script" , $txt );
$txt = preg_replace( "#<(\s+?)?/(\s+?)?s(\s+?)?c(\s+?)?r(\s+?)?i(\s+?)?p(\s+?)?t#is", "&lt;/script", $txt );
$txt = preg_replace( '#<(\s+?)?s(\s+?)?c(\s+?)?r(\s+?)?i(\s+?)?p(\s+?)?t#is' , "&lt;script" , $txt );
$txt = preg_replace( '#<(\s+?)?/(\s+?)?s(\s+?)?c(\s+?)?r(\s+?)?i(\s+?)?p(\s+?)?t#is', "&lt;/script", $txt );
}
/* got a tag? */
if ( $tag )
{
$tag = strip_tags( $tag, '<br>' );
switch ($tag)
{
case 'entry':
case 'blog':
case 'topic':
case 'post':
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
if ( ! is_numeric( $test ) )
{
$txt = false;
}
break;
case 'acronym':
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
$test1 = str_replace( array( '<', ">", '[', ']' ), "", $test );//IPSText::alphanumericalClean( $test, '.+&#; ' );
if ( $test != $test1 )
{
$txt = false;
}
break;
case 'email':
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
$test = ( IPSText::checkEmailAddress( $test ) ) ? $txt : FALSE;
break;
case 'font':
case 'color':
case 'background':
/* Make sure it's clean */
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
$test1 = IPSText::alphanumericalClean( $test, '#.+, ' );
if ( $test != $test1 )
{
$txt = false;
}
break;
default:
$_regex = null;
foreach( $this->cache->getCache('bbcode') as $bbcode )
{
if( $bbcode['bbcode_tag'] == $tag )
{
$_regex = $bbcode['bbcode_custom_regex'];
break;
}
}
if( $_regex )
{
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
if( !preg_match( $_regex, $test ) )
{
$txt = false;
}
}
break;
}
/* If we didn't actually get any option data, then return false */
$test = str_replace( array( '"', "'", '&quot;', '&#39;' ), "", $txt );
if ( strlen($txt) AND strlen( $test ) < 1 )
{
$txt = false;
}
if ( $txt === false )
{
return false;
}
/* Still here? Safety, then */
$txt = strip_tags( $txt, '<br>' );
if( strpos( $txt, '[' ) !== false OR strpos( $txt, ']' ) !== false )
{
$txt = str_replace( array( '[', ']' ), array( '&#91;', '&#93;' ), $txt );
}
}
//-----------------------------------------
// Here we can do some generic checking for XSS
// This should not be considered fool proof, though can provide
@@ -446,10 +553,10 @@ class class_bbcode_core
$txt = preg_replace( "/(j)avascript/i" , "\\1&#097;v&#097;script", $txt );
//$txt = str_ireplace( "alert" , "&#097;lert" , $txt );
$txt = str_ireplace( "behavior" , "beh&#097;vior" , $txt );
$txt = preg_replace( "/(e)((\/\*.*?\*\/)*)x((\/\*.*?\*\/)*)p((\/\*.*?\*\/)*)r((\/\*.*?\*\/)*)e((\/\*.*?\*\/)*)s((\/\*.*?\*\/)*)s((\/\*.*?\*\/)*)i((\/\*.*?\*\/)*)o((\/\*.*?\*\/)*)n/is" , "\\1xp<b></b>ressi&#111;n" , $txt );
$txt = preg_replace( "/(e)((\\\|&#092;)*)x((\\\|&#092;)*)p((\\\|&#092;)*)r((\\\|&#092;)*)e((\\\|&#092;)*)s((\\\|&#092;)*)s((\\\|&#092;)*)i((\\\|&#092;)*)o((\\\|&#092;)*)n/is" , "\\1xp<b></b>ressi&#111;n" , $txt );
$txt = preg_replace( "/m((\\\|&#092;)*)o((\\\|&#092;)*)z((\\\|&#092;)*)\-((\\\|&#092;)*)b((\\\|&#092;)*)i((\\\|&#092;)*)n((\\\|&#092;)*)d((\\\|&#092;)*)i((\\\|&#092;)*)n((\\\|&#092;)*)g/is" , "moz-<b></b>b&#105;nding" , $txt );
//$txt = preg_replace( "/(b)(e)(h)(a)(v)(i)(o)(r)/is" , "\\1\\2\\3<b></b>\\4\\5\\6\\7\\8" , $txt );
$txt = preg_replace( '/(e)((\/\*.*?\*\/)*)x((\/\*.*?\*\/)*)p((\/\*.*?\*\/)*)r((\/\*.*?\*\/)*)e((\/\*.*?\*\/)*)s((\/\*.*?\*\/)*)s((\/\*.*?\*\/)*)i((\/\*.*?\*\/)*)o((\/\*.*?\*\/)*)n/is' , "\\1xp<b></b>ressi&#111;n" , $txt );
$txt = preg_replace( '/(e)((\\\|&#092;)*)x((\\\|&#092;)*)p((\\\|&#092;)*)r((\\\|&#092;)*)e((\\\|&#092;)*)s((\\\|&#092;)*)s((\\\|&#092;)*)i((\\\|&#092;)*)o((\\\|&#092;)*)n/is' , "\\1xp<b></b>ressi&#111;n" , $txt );
$txt = preg_replace( '/m((\\\|&#092;)*)o((\\\|&#092;)*)z((\\\|&#092;)*)\-((\\\|&#092;)*)b((\\\|&#092;)*)i((\\\|&#092;)*)n((\\\|&#092;)*)d((\\\|&#092;)*)i((\\\|&#092;)*)n((\\\|&#092;)*)g/is' , "moz-<b></b>b&#105;nding" , $txt );
$txt = str_ireplace( "about:" , "&#097;bout:" , $txt );
$txt = str_ireplace( "<body" , "&lt;body" , $txt );
$txt = str_ireplace( "<html" , "&lt;html" , $txt );
@@ -524,11 +631,11 @@ class class_bbcode_core
foreach( $this->cache->getCache('badwords') as $r )
{
$replace = $r['swop'] ? $r['swop'] : '######';
$r['type'] = preg_quote( $r['type'], "/" );
if ( $r['m_exact'] )
{
$text = preg_replace( "/(^|\b|\s)" . $r['type'] . "(\b|!|\?|\.|,|$)/i", "\\1{$replace}\\2", $text );
$r['type'] = preg_quote( $r['type'], "/" );
$text = preg_replace( "/(^|a-zа-я0-9|\s)" . $r['type'] . "([^a-zа-я0-9]|!|\?|\.|,|$)/ui", "\\1{$replace}\\2", $text );
}
else
{
@@ -538,11 +645,11 @@ class class_bbcode_core
if( $r['type'] == 'ass' )
{
$text = preg_replace( "/(?<!cl)" . $r['type'] . "/i", $replace, $text );
$text = preg_replace( "/(?<!cl)" . $r['type'] . "/i", $replace, $text );
}
else
{
$text = str_ireplace( $r['type'], $replace, $text );
$text = str_ireplace( $r['type'], $replace, $text );
}
}
}
@@ -551,6 +658,75 @@ class class_bbcode_core
return $text ? $text : $temp_text;
}
/**
* Check against blacklisted URLs
*
* @access public
* @param string Raw posted text
* @return bool False if blacklisted url present, otherwise true
*/
public function checkBlacklistUrls( $t )
{
if( !$t )
{
return true;
}
if ( $this->settings['ipb_use_url_filter'] )
{
$list_type = $this->settings['ipb_url_filter_option'] == "black" ? "blacklist" : "whitelist";
if( $this->settings['ipb_url_' . $list_type ] )
{
$list_values = array();
$list_values = explode( "\n", str_replace( "\r", "", $this->settings['ipb_url_' . $list_type ] ) );
if( $list_type == 'whitelist' )
{
$list_values[] = "http://{$_SERVER['HTTP_HOST']}/*";
}
if ( count( $list_values ) )
{
$good_url = 0;
foreach( $list_values as $my_url )
{
if( !trim($my_url) )
{
continue;
}
$my_url = preg_quote( $my_url, '/' );
$my_url = str_replace( '\*', "(.*?)", $my_url );
if ( $list_type == "blacklist" )
{
if( preg_match( '/' . $my_url . '/i', $t ) )
{
return false;
}
}
else
{
if ( preg_match( '/' . $my_url . '/i', $t ) )
{
$good_url = 1;
}
}
}
if ( ! $good_url AND $list_type == "whitelist" )
{
return false;
}
}
}
}
return true;
}
/**
* Custom word wrap : attempts to not break HTML tags (*ha!)
@@ -601,7 +777,7 @@ class class_bbcode_core
$totalLength = strlen( $txt );
$curPos = 0;
$charsSince = 0;
$iterations = 0;
//-----------------------------------------
// Loop over each char
//-----------------------------------------
@@ -609,6 +785,14 @@ class class_bbcode_core
while( $curPos < $totalLength )
{
$curPos++;
/**
* @link http://community.invisionpower.com/tracker/issue-23818-wordwrap-bug-with-amp%3Blt%3B/
*/
if( $curPos < 1 )
{
break;
}
//-----------------------------------------
// We within a tag?
@@ -763,12 +947,12 @@ class class_bbcode_core
static $iteration = array();
if( array_key_exists( $tag, $iteration ) AND $iteration[ $tag ] > 2000 )
if( array_key_exists( $tag, $iteration ) AND $iteration[ $tag ] > $this->settings['max_bbcodes_per_post'] )
{
return $txt;
}
$iteration[ $tag ]++;
$iteration[ $tag ] = isset($iteration[ $tag ]) ? $iteration[ $tag ]++ : 1;
// Got Quotes (tm)? or any tag really
if( stripos( $txt, '[' . $tag ) !== false )
@@ -861,9 +1045,9 @@ class class_bbcode_core
else
{
//$txt = preg_replace( "#\[{$bbcode['bbcode_tag']}\](.+?)\[/{$bbcode['bbcode_tag']}\]#is", "\\1 ", $txt );
$txt = preg_replace( "#\[{$bbcode['bbcode_tag']}=(.+?)\](.+?)\[/{$bbcode['bbcode_tag']}\]#is", "\\2 ", $txt );
$txt = str_replace( "[{$bbcode['bbcode_tag']}]", '', $txt );
$txt = str_replace( "[/{$bbcode['bbcode_tag']}]", '', $txt );
$txt = preg_replace( "#\[{$bbcode['bbcode_tag']}=([^\]]+?)\](.+?)\[/{$bbcode['bbcode_tag']}\]#ius", "\\2 ", $txt );
$txt = str_ireplace( "[{$bbcode['bbcode_tag']}]", '', $txt );
$txt = str_ireplace( "[/{$bbcode['bbcode_tag']}]", '', $txt );
}
//-----------------------------------------
@@ -880,17 +1064,17 @@ class class_bbcode_core
if( $bbcode['bbcode_useoption'] )
{
$regex .= '=([^\]]+)';
$regex .= '=([^\]]+?)';
}
$txt = preg_replace( "#\[{$regex}\]#is", " ", $txt );
}
}
$txt = preg_replace( "#\[(.+?)\]#is", " ", $txt );
$txt = preg_replace( "#\[(.+?)=(.+?)\]#is", " ", $txt );
$txt = preg_replace( "#\[/(.+?)\]#is", " ", $txt );
$txt = preg_replace( "#\[attachment=(.+?)\]#is", " ", $txt );
//$txt = preg_replace( "#\[(.+?)\]#is", " ", $txt );
$txt = preg_replace( '#\[([^\]]+?)=([^\]]+?)\]#is', " ", $txt );
$txt = preg_replace( '#\[/([^\]]+?)\]#is', " ", $txt );
$txt = preg_replace( '#\[attachment=(.+?)\]#is', " ", $txt );
$txt = str_replace( '[*]', '', $txt );
return $txt;
@@ -919,14 +1103,31 @@ class class_bbcode_core
$_codeboxes = array();
$_increment = 0;
$_codes = array();
while( preg_match( "/\[code\](.+?)\[\/code\]/is", $t, $matches ) )
foreach( $this->_bbcodes['display'] as $code => $data )
{
$_codeboxes[ $_increment ] = $matches[0];
$t = str_replace( $matches[0], "__CODEBOX_{$_increment}__", $t );
$_increment++;
if( $data['bbcode_no_parsing'] )
{
if( $code == 'img' )
{
continue;
}
$_codes[] = $code;
}
}
foreach( $_codes as $_aCode )
{
while( preg_match( "/\[{$_aCode}\](.+?)\[\/{$_aCode}\]/is", $t, $matches ) )
{
$_codeboxes[ $_increment ] = $matches[0];
$t = str_replace( $matches[0], "__CODEBOX_{$_increment}__", $t );
$_increment++;
}
}
//-----------------------------------------
@@ -1020,7 +1221,7 @@ class class_bbcode_core
// Remove all macros
//-----------------------------------------
$t = preg_replace( "#<\{.+?\}>#", "", $t );
$t = preg_replace( '#<\{.+?\}>#', "", $t );
//-----------------------------------------
// Reset the bbcodes to be safe
@@ -1093,7 +1294,7 @@ class class_bbcode_core
{
$txt = substr_replace( $txt, '', $position, strlen($_emoCode) );
$position += strlen($replace);
$position += strlen($_emoCode);
}
$emoPosition = $position + 1;
@@ -1123,13 +1324,15 @@ class class_bbcode_core
//-----------------------------------------
$this->_resetPointers();
$this->cache->updateCacheWithoutSaving( '_tmp_bbcode_media', 0 );
$this->cache->updateCacheWithoutSaving( '_tmp_bbcode_images', 0 );
//-----------------------------------------
// Remove session id's from any post
//-----------------------------------------
//$txt = htmlspecialchars( $txt, ENT_NOQUOTES );
$txt = preg_replace_callback( "#(\?|&amp;|;|&)s=([0-9a-zA-Z]){32}(&amp;|;|&|$)?#", array( $this, '_bashSession' ), $txt );
$txt = preg_replace_callback( '#(\?|&amp;|;|&)s=([0-9a-zA-Z]){32}(&amp;|;|&|$)?#', array( $this, '_bashSession' ), $txt );
//-----------------------------------------
// convert <br> to \n
@@ -1164,7 +1367,7 @@ class class_bbcode_core
if ( $this->parse_bbcode )
{
$this->parseBbcode( $txt, 'db' );
$txt = $this->parseBbcode( $txt, 'db' );
}
//-----------------------------------------
@@ -1177,6 +1380,12 @@ class class_bbcode_core
$txt = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $txt );
}
/* Parse smililes before bbcode, and remove elemnts that will not be parsed on display. Bug Fix: #20964 */
// Parsing here causes nonparsed stuff to be double stored in the storeNonParsed array. This causes problems
// when you limit images per post.
// @link http://community.invisionpower.com/tracker/issue-23024-images-per-post-not-working
// $txt = $this->_storeNonParsed( $txt, 'display' );
//-----------------------------------------
// Parse smilies
//-----------------------------------------
@@ -1184,7 +1393,7 @@ class class_bbcode_core
if ( $this->parse_smilies )
{
$codes_seen = array();
if ( count( $this->cache->getCache('emoticons') ) > 0 )
{
foreach( $this->cache->getCache('emoticons') as $row )
@@ -1193,62 +1402,62 @@ class class_bbcode_core
{
continue;
}
$code = $row['typed'];
if ( in_array( $code, $codes_seen ) )
{
continue;
}
$codes_seen[] = $code;
//-----------------------------------------
// Now, check for the html safe versions
//-----------------------------------------
$_emoCode = str_replace( '<', '&lt;', str_replace( '>', '&gt;', $code ) );
$_emoImage = $row['image'];
$emoPosition = 0;
//-----------------------------------------
// These are chars that can't surround the emo
//-----------------------------------------
$invalidWrappers = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\"";
//-----------------------------------------
// Have any more chars to look at?
//-----------------------------------------
while( ( $position = stripos( $txt, $_emoCode, $emoPosition ) ) !== false )
{
//-----------------------------------------
// Are we at the start of the string, or
// is the preceeding char not an invalid wrapper?
//-----------------------------------------
if( ( $position === 0 OR stripos( $invalidWrappers, substr( $txt, $position-1, 1 ) ) === false )
//-----------------------------------------
// Are we at the end of the string or is the
// next char not an invalid wrapper?
//-----------------------------------------
AND ( strlen($txt) == ($position + strlen($_emoCode)) OR stripos( $invalidWrappers, substr( $txt, ($position + strlen($_emoCode)), 1 ) ) === false ) )
AND ( strlen($txt) == ($position + strlen($_emoCode)) OR stripos( $invalidWrappers, substr( $txt, ($position + strlen($_emoCode)), 1 ) ) === false ) )
{
//-----------------------------------------
// Replace the emoticon and increment position counter
//-----------------------------------------
$replace = $this->_retrieveSmiley( $_emoCode, $_emoImage );
$txt = substr_replace( $txt, $replace, $position, strlen($_emoCode) );
$position += strlen($replace);
}
$emoPosition = $position + 1;
if( $emoPosition > strlen($txt) )
{
break;
@@ -1264,6 +1473,24 @@ class class_bbcode_core
$this->error = 'too_many_emoticons';
}
}
/* Put alt tags in */
if( is_array( $this->emoticon_alts ) && count( $this->emoticon_alts ) )
{
foreach( $this->emoticon_alts as $r )
{
$txt = str_replace( $r[0], $r[1], $txt );
}
}
}
/* Put back non parsed code. Bug Fix: #20964 */
if( is_array( $this->noParseStorage ) && count( $this->noParseStorage ) )
{
foreach( $this->noParseStorage as $r )
{
$txt = str_replace( $r['find'], $r['replace'], $txt );
}
}
//-----------------------------------------
@@ -1284,6 +1511,9 @@ class class_bbcode_core
*/
public function preDisplayParse( $txt="" )
{
$this->cache->updateCacheWithoutSaving( '_tmp_bbcode_media', 0 );
$this->cache->updateCacheWithoutSaving( '_tmp_bbcode_images', 0 );
if ( $this->parse_html )
{
//-----------------------------------------
@@ -1325,12 +1555,6 @@ class class_bbcode_core
}
IPSDebug::setMemoryDebugFlag( "PreDisplayParse - applied wordwrap", $_NOW );
//-----------------------------------------
// Protect against XSS
//-----------------------------------------
$txt = $this->checkXss($txt);
//-----------------------------------------
// Fix line breaks
@@ -1340,7 +1564,7 @@ class class_bbcode_core
{
$txt = str_replace( "~~~~~_____~~~~~", '<br />', $txt );
}
//-----------------------------------------
// And fix old youtube embedded videos..
//-----------------------------------------
@@ -1427,11 +1651,13 @@ class class_bbcode_core
$this->emoticon_count++;
$this->emoticon_alts[] = array( "#EMO_ALT_{$this->emoticon_count}#", $_emoCode );
//-----------------------------------------
// Return
//-----------------------------------------
return "<img src='" . $this->settings['emoticons_url'] . "/{$_emoImage}' class='bbc_emoticon' alt='{$_emoCode}' />";
return "<img src='" . $this->settings['emoticons_url'] . "/{$_emoImage}' class='bbc_emoticon' alt='#EMO_ALT_{$this->emoticon_count}#' />";
}
/**
@@ -1454,15 +1680,6 @@ class class_bbcode_core
$txt = $this->_storeNonParsed( $txt, $cur_method );
}
//-----------------------------------------
// Auto parse URLs (only if this is full sweep)
//-----------------------------------------
if( !$_code AND $cur_method == 'display' )
{
$txt = preg_replace_callback( "#(^|\s|>|\](?<!\[url\]))((http|https|news|ftp)://\w+[^,\s\<\[]+)#is", array( $this, '_autoParseUrls' ), $txt );
}
//-----------------------------------------
// Regular replacing
//-----------------------------------------
@@ -1485,7 +1702,7 @@ class class_bbcode_core
{
$mygroups = array_diff( array_merge( $mygroups, explode( ',', IPSText::cleanPermString( $this->parsing_mgroup_others ) ) ), array('') );
}
foreach( $groups as $g_id )
{
if( in_array( $g_id, $mygroups ) )
@@ -1630,7 +1847,7 @@ class class_bbcode_core
// New instance of class, store in plugin registry for use next time
//-----------------------------------------
$plugin = new $_classname( $this->registry );
$plugin = new $_classname( $this->registry, $this );
$method = "pre" . ucwords($cur_method) . "Parse";
$this->plugins[ md5($_bbcode['bbcode_tag']) ] = $plugin;
@@ -1674,7 +1891,7 @@ class class_bbcode_core
//-----------------------------------------
foreach( $_tags as $_tag )
{
{
//-----------------------------------------
// Are we only parsing one code?
//-----------------------------------------
@@ -1710,7 +1927,7 @@ class class_bbcode_core
// Stop infinite loops
//-----------------------------------------
if( $_iteration > 2000 )
if( $_iteration > $this->settings['max_bbcodes_per_post'] )
{
break;
}
@@ -1790,46 +2007,76 @@ class class_bbcode_core
continue;
}
}
//-----------------------------------------
// If this is a single tag, that's it
// Protect against XSS
//-----------------------------------------
if( $_bbcode['bbcode_single_tag'] )
$_optionStrLen = IPSText::mbstrlen( $_option );
$_optionSlenstr = strlen($_option);
$_option = $this->checkXss($_option, false, $_tag);
/* Not parsing URls? */
if ( isset( $_bbcode['bbcode_no_auto_url_parse'] ) AND $_bbcode['bbcode_no_auto_url_parse'] )
{
$txt = substr_replace( $txt, $this->_bbcodeToHtml( $_bbcode, $_option, '' ), $this->cur_pos, ($open_length + strlen($_option) + 1) );
$_option = preg_replace( "#(http|https|news|ftp)://#i", "\\1&#58;//", $_option );
}
//-----------------------------------------
// Otherwise replace out the content too
//-----------------------------------------
else
if ( $_option !== FALSE )
{
$close_tag = '[/' . $_tag . ']';
if( stripos( $txt, $close_tag, $new_pos ) !== false )
//-----------------------------------------
// If this is a single tag, that's it
//-----------------------------------------
if( $_bbcode['bbcode_single_tag'] )
{
$_content = substr( $txt, ($this->cur_pos + $open_length + strlen($_option) + 1), (stripos( $txt, $close_tag, $this->cur_pos ) - ($this->cur_pos + $open_length + strlen($_option) + 1)) );
$txt = substr_replace( $txt, $this->_bbcodeToHtml( $_bbcode, $_option /*? $_option : $_content*/, $_content ), $this->cur_pos, (stripos( $txt, $close_tag, $this->cur_pos ) + strlen($close_tag) - $this->cur_pos) );
$txt = substr_replace( $txt, $this->_bbcodeToHtml( $_bbcode, $_option, '' ), $this->cur_pos, ($open_length + $_optionSlenstr + 1) );
}
//-----------------------------------------
// Otherwise replace out the content too
//-----------------------------------------
else
{
//-----------------------------------------
// If there's no close tag, no need to continue
//-----------------------------------------
break;
$close_tag = '[/' . $_tag . ']';
if( stripos( $txt, $close_tag, $new_pos ) !== false )
{
$_content = substr( $txt, ($this->cur_pos + $open_length + $_optionSlenstr + 1), (stripos( $txt, $close_tag, $this->cur_pos ) - ($this->cur_pos + $open_length + $_optionSlenstr + 1)) );
if( $_bbcode['bbcode_useoption'] AND $_bbcode['bbcode_optional_option'] AND !$_option )
{
$_option = $_content;
$_option = $this->checkXss($_option, false, $_tag);
}
/* Not parsing URls? */
if ( isset( $_bbcode['bbcode_no_auto_url_parse'] ) AND $_bbcode['bbcode_no_auto_url_parse'] )
{
$_content = preg_replace( "#(http|https|news|ftp)://#i", "\\1&#58;//", $_content );
}
$txt = substr_replace( $txt, $this->_bbcodeToHtml( $_bbcode, $_option /*? $_option : $_content*/, $_content ), $this->cur_pos, (stripos( $txt, $close_tag, $this->cur_pos ) + strlen($close_tag) - $this->cur_pos) );
}
else
{
//-----------------------------------------
// If there's no close tag, no need to continue
//-----------------------------------------
break;
}
}
}
//-----------------------------------------
// And reset current position to end of open tag
// Bug 14744 - if we jump to $new_pos it can skip the opening of the next bbcode tag
// when the replacement HTML is shorter than the full bbcode representation...
//-----------------------------------------
$this->cur_pos = strpos( $txt, $open_tag ) ? strpos( $txt, $open_tag ) : $this->cur_pos + 1; //$new_pos;
$this->cur_pos = stripos( $txt, $open_tag ) ? stripos( $txt, $open_tag ) : $this->cur_pos + 1; //$new_pos;
if( $this->cur_pos > strlen($txt) )
{
@@ -1859,6 +2106,44 @@ class class_bbcode_core
{
$txt = $this->_parseNonParsed( $txt, $cur_method );
}
//-----------------------------------------
// Auto parse URLs (only if this is full sweep)
//-----------------------------------------
if( !$_code AND $cur_method == 'display' )
{
/* If we parse <a href='http://site.com'>http://site[color=red].com[/color]</a>, it breaks
* @link http://community.invisionpower.com/tracker/issue-24318-colors-in-urls-as-names-breaks-them/
* Here we will extract <a></a> pairs, put in */
$_storedLinks = array();
$_counter = 0;
while( preg_match( "/<a href='(.+?)'(.*?)>(.+?)<\/a>/is", $txt, $matches ) )
{
$_counter++;
$_storedLinks[ $_counter ] = $matches[0];
$txt = str_replace( $matches[0], '<!--LINKS_TEMP--' . $_counter . '-->', $txt );
}
/* Capture 'href="' and '</a>' as [URL] is now parsed first, we discard these in _autoParseUrls */
/**
* @link http://community.invisionpower.com/tracker/issue-23726-parser-wrong-url-with-unicode-chars/
* I had to add the /u modifier to correct this. Previously, the first byte sequence of the word was matching \s.
* @link http://community.invisionpower.com/tracker/issue-24684-posts-are-blankmissing/
* Reverting this fix as it's breaking in some environments - not really sure what we can do about this at this point
*/
//$opts = ( IPS_DOC_CHAR_SET == 'UTF-8' ) ? 'isu' : 'is';
$opts = "is";
$txt = preg_replace_callback( '#(^|\s|\)|\(|\{|\}|>|\]|\[|href=\S)((http|https|news|ftp)://(?:[^<>\)\[\"\s]+|[a-zA-Z0-9/\._\-!&\#;,%\+\?:=]+))(</a>)?#' . $opts, array( $this, '_autoParseUrls' ), $txt );
/* Now put back stored links */
foreach( $_storedLinks as $_inc => $_storedLink )
{
$txt = str_replace( '<!--LINKS_TEMP--' . $_inc . '-->', $_storedLink, $txt );
}
}
return $txt;
}
@@ -1939,7 +2224,7 @@ class class_bbcode_core
//-----------------------------------------
$replaceCode = $_bbcode['bbcode_replace'];
$replaceCode = str_replace( '{base_url}', $this->settings['base_url'], $replaceCode );
$replaceCode = str_replace( '{base_url}', $this->settings['board_url'] . '/index.php?', $replaceCode );
$replaceCode = str_replace( '{image_url}', $this->settings['img_url'], $replaceCode );
preg_match( '/\{text\.(.+?)\}/i', $replaceCode, $matches );
@@ -1998,6 +2283,7 @@ class class_bbcode_core
$txt = str_replace( "&amp;" , "&", $txt );
$txt = str_replace( "&gt;" , ">", $txt );
$txt = str_replace( "&lt;" , "<", $txt );
$txt = str_replace( "&#62;" , ">", $txt );
$txt = str_replace( "&quot;", '"', $txt );
return $txt;
@@ -2130,7 +2416,7 @@ class class_bbcode_core
else if( (strpos( $txt, ']', $_curPosition ) - ( $_curPosition + $open_length )) !== 0 )
{
$_curPosition = strpos( $txt, ']', $_curPosition );
$_curPosition = ( strpos( $txt, ']', $_curPosition ) !== false ) ? strpos( $txt, ']', $_curPosition ) : $_curPosition + 1;
continue;
}
@@ -2138,7 +2424,7 @@ class class_bbcode_core
// Grab the new position to jump to
//-----------------------------------------
$new_pos = strpos( $txt, ']', $_curPosition );
$new_pos = ( strpos( $txt, ']', $_curPosition ) !== false ) ? strpos( $txt, ']', $_curPosition ) : $_curPosition + 1;
//-----------------------------------------
// If this is a single tag, that's it
@@ -2146,8 +2432,8 @@ class class_bbcode_core
if( $_bbcode['bbcode_single_tag'] )
{
$_currentContent = substr( $txt, $_curPosition, ($open_length + strlen($_option) + 1) );
$txt = substr_replace( $txt, $_thisTag, $_curPosition, ($open_length + strlen($_option) + 1) );
$_currentContent = substr( $txt, $_curPosition, ($open_length + IPSText::mbstrlen($_option) + 1) );
$txt = substr_replace( $txt, $_thisTag, $_curPosition, ($open_length + IPSText::mbstrlen($_option) + 1) );
}
//-----------------------------------------
@@ -2170,7 +2456,7 @@ class class_bbcode_core
}
}
$this->noParseStorage[] = array(
$this->noParseStorage[$this->_storedNoParsing] = array(
'find' => $_thisTag,
'replace' => $_currentContent,
'code' => $_tag,
@@ -2202,7 +2488,7 @@ class class_bbcode_core
if( is_array( $this->noParseStorage ) AND count( $this->noParseStorage ) )
{
$this->resetPerPost();
foreach( $this->noParseStorage as $replacement )
{
//-----------------------------------------
@@ -2221,12 +2507,23 @@ class class_bbcode_core
$replacement['replace'] = str_replace( "<", "&lt;" , $replacement['replace'] );
$replacement['replace'] = str_replace( '"', "&quot;", $replacement['replace'] );
$replacement['replace'] = str_replace( '&amp;#60;', "&lt;", $replacement['replace'] );
$replacement['replace'] = str_replace( '&amp;#092;', "&#092;", $replacement['replace'] );
//$replacement['replace'] = str_replace( '&lt;br /&gt;', "<br />", $replacement['replace'] );
}
$_final = $this->parseBbcode( $replacement['replace'], $cur_method, $replacement['code'] );
$_final = $this->preEditParse( $_final );
/* Bug fix: #20973 */
if( preg_match( '/\<\!\-\-NoParse(\d+)\-\-\>/', $_final, $matches ) )
{
if( $matches[1] )
{
$_final = str_replace( "<!--NoParse{$matches[1]}-->", $this->noParseStorage[ $matches[1] ]['replace'], $_final );
unset( $this->noParseStorage[ $matches[1] ] );
}
}
//-----------------------------------------
// We don't want any bbcodes to parse..
//-----------------------------------------
@@ -2252,7 +2549,88 @@ class class_bbcode_core
*/
private function _autoParseUrls( $matches )
{
return $this->parseBbcode( $matches[1] . '[url]' . $matches[2] . '[/url]', 'display', 'url' );
$_extra = '';
/* Basic checking */
if ( stristr( $matches[1], 'href' ) )
{
return $matches[0];
}
if( strlen( $matches[2] ) < 12 )
{
return $matches[0];
}
if ( isset( $matches[4] ) AND stristr( $matches[4], '</a>' ) )
{
return $matches[0];
}
/* Check for XSS */
if ( ! IPSText::xssCheckUrl( $matches[2] ) )
{
return $matches[0];
}
if( substr( $matches[2], -1 ) == ',' )
{
$matches[2] = rtrim( $matches[2], ',' );
$_extra = ',';
}
/* Check for ! which is &#xx; at this point */
if( preg_match( '/&#\d+?;$/', $matches[2], $_m ) )
{
$matches[2] = str_replace( $_m[0], '', $matches[2] );
$_extra = $_m[0];
}
/* Is this a media URL? */
if( $this->settings['bbcode_automatic_media'] and isset( $this->_bbcodes['display']['media'] ) and ( $this->_bbcodes['display']['media']['bbcode_sections'] == 'all' or in_array( $this->parsing_section, explode( ',', $this->_bbcodes['display']['media']['bbcode_sections'] ) ) ) )
{
$media = $this->cache->getCache( 'mediatag' );
if( is_array($media) AND count($media) )
{
foreach( $media as $type => $r )
{
if( preg_match( "#^" . $r['match'] . "$#is", $matches[2] ) )
{
//-----------------------------------------
// Do it this way so we can capture disable_flash
//-----------------------------------------
$this->cache->updateCacheWithoutSaving( '_tmp_autoparse_media', 1 );
$_result = $this->parseBbcode( $matches[1] . '[media]' . $matches[2] . '[/media]' . $_extra, 'display', 'media' );
$this->cache->updateCacheWithoutSaving( '_tmp_autoparse_media', 0 );
return $_result;
}
}
}
}
/* It's not media - so we'll use [url] - check we're allowed first */
if( !isset( $this->_bbcodes['display']['url'] ) or ( $this->_bbcodes['display']['url']['bbcode_sections'] != 'all' and !in_array( $this->parsing_section, explode( ',', $this->_bbcodes['display']['url']['bbcode_sections'] ) ) ) )
{
// We're not allowed to use [url] here
return $matches[0];
}
/* Ensure bbcode is stripped for the actual URL */
/* @link http://community.invisionpower.com/tracker/issue-22580-bbcode-breaks-link-add-bold-formatting-to-part-of-link/ */
if ( preg_match( '#\[\w#', $matches[2] ) )
{
$wFormatting = $matches[2];
$matches[2] = $this->stripAllTags( $matches[2] );
return $this->parseBbcode( $matches[1] . '[url="' . $matches[2] . '"]' . $wFormatting . '[/url]' . $_extra, 'display', 'url' );
}
else
{
return $this->parseBbcode( $matches[1] . '[url]' . $matches[2] . '[/url]' . $_extra, 'display', 'url' );
}
}
/**
File diff suppressed because it is too large. Load diff
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* BBCode parsing core - legacy routine
* Last Updated: $Date: 2009-07-06 21:23:35 -0400 (Mon, 06 Jul 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 4843 $
* @version $Revision: 5713 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -1,17 +1,19 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Control Panel Functions
* Last Updated: $Date: 2009-10-21 20:34:34 -0400 (Wed, 21 Oct 2009) $
* Last Updated: $Date: 2010-09-15 19:24:12 -0400 (Wed, 15 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since Tue. 17th August 2004
* @version $Rev: 5256 $
* @version $Rev: 6882 $
*
*/
class adminFunctions
@@ -68,7 +70,7 @@ class adminFunctions
// Message in a bottle?
//------------------------------------------
if( $this->request['messageinabottleacp'] )
if( isset($this->request['messageinabottleacp']) AND $this->request['messageinabottleacp'] )
{
$this->request['messageinabottleacp'] = IPSText::getTextClass('bbcode')->xssHtmlClean( IPSText::UNhtmlspecialchars( urldecode( $this->request['messageinabottleacp'] ) ) );
$this->registry->output->global_message = $this->request['messageinabottleacp'];
@@ -125,7 +127,7 @@ class adminFunctions
$cookie = ( $_test['sys_cookie'] ) ? unserialize( $_test['sys_cookie'] ) : array();
return $cookie[ $key ];
return ( isset( $cookie[ $key ] ) ) ? $cookie[ $key ] : null;
}
/**
@@ -171,15 +173,13 @@ class adminFunctions
*
* @access public
* @return string MD5 secure hash
* @deprecated Don't think we are using this anywhere now
* @see getSecurityKey()
**/
public function generateSecureHash()
{
/* Generate Secure Hash */
$ip_octets = explode( ".", $this->ip_address );
$crypt_salt = md5( $this->settings['sql_user'].$this->settings['sql_database'].$this->settings['sql_pass'] );
$key = md5( crypt( $this->memberData['member_joined'] . "(&)" . $ip_octets[0] . '(&)' . $ip_octets[1] . '(&)' . $this->memberData['member_login_key'], $crypt_salt ) );
$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 ) );
return $key;
}
@@ -194,7 +194,7 @@ class adminFunctions
**/
public function getSecurityKey()
{
return md5( $this->memberData['email'] . '^' . $this->memberData['joined'] . '^' . $this->memberData['ip_address'] . md5( $this->settings['sql_pass'] ) );
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'] ) );
}
/**
@@ -218,7 +218,7 @@ class adminFunctions
}
else
{
$this->registry->output->showError( $this->lang->words['func_security_mismatch'], 2100 );
$this->registry->output->showError( $this->lang->words['func_security_mismatch'], 2100, null, null, 403 );
exit();
}
}
@@ -264,8 +264,9 @@ class adminFunctions
// Upload
//-----------------------------------------
$FILE_NAME = $_FILES['FILE_UPLOAD']['name'];
$FILE_TYPE = $_FILES['FILE_UPLOAD']['type'];
$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
@@ -277,9 +278,9 @@ class adminFunctions
if ( $FILE_NAME AND ( $FILE_NAME != 'none' ) )
{
if ( move_uploaded_file( $_FILES[ 'FILE_UPLOAD' ]['tmp_name'], DOC_IPS_ROOT_PATH . "uploads/" . $FILE_NAME ) )
if ( move_uploaded_file( $_FILES[ 'FILE_UPLOAD' ]['tmp_name'], $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
$location = DOC_IPS_ROOT_PATH . "uploads/" . $FILE_NAME;
$location = $UPLOAD_DIR . "/" . $FILE_NAME;
}
}
@@ -305,9 +306,9 @@ class adminFunctions
}
/* Unlink the tmp file if it exists */
if ( file_exists( DOC_IPS_ROOT_PATH . "uploads/" . $FILE_NAME ) )
if ( file_exists( $UPLOAD_DIR . "/" . $FILE_NAME ) )
{
@unlink( DOC_IPS_ROOT_PATH . "uploads/" . $FILE_NAME );
@unlink( $UPLOAD_DIR . "/" . $FILE_NAME );
}
return $content;
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* Localization Class
* IP.Board v3.1.4
* Localization Class.
*
* Used for handling language text, money formatting, etc.
* Last Updated: $Date: 2009-11-10 10:11:01 -0500 (Tue, 10 Nov 2009) $
* Last Updated: $Date: 2010-10-06 06:09:32 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author Joshua Williams <josh@invisionpower.com>
* @version $Rev: 5343 $
* @version $Rev: 6946 $
* @since 1.0
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @link http://www.iinvisionpower.com
* @package Invision Power Board
* @license http://www.invisionpower.com/community/board/license.html
* @link http://www.invisionpower.com
* @package IP.Board
*/
class class_localization
@@ -69,7 +71,7 @@ class class_localization
* @access public
* @var string
*/
public $local = "en_US";
public $local = "ru_RU";
/**
* Array of loaded language files
@@ -93,7 +95,7 @@ class class_localization
* @access public
* @var bool
*/
public $load_from_db = 0;
public $load_from_db = false;
/**
* Force UK/English language
@@ -121,6 +123,15 @@ class class_localization
$this->request = $registry->fetchRequest();
$this->memberData =& $registry->member()->fetchMemberData();
/* Prevent notices */
$this->memberData['member_id'] = !isset($this->memberData['member_id']) ? 0 : $this->memberData['member_id'];
/* Load from database */
if( $this->settings['safe_mode_skins'] && ! IN_DEV )
{
$this->load_from_db = true;
}
/* Rebuild the cache if needed */
if( ! $this->caches['lang_data'] )
{
@@ -188,7 +199,7 @@ class class_localization
'LONG' => $this->settings['clock_long'] ? $this->settings['clock_long'] : '%d %B %Y - %I:%M %p',
'TINY' => $this->settings['clock_tiny'] ? $this->settings['clock_tiny'] : '%d %b %Y - %H:%M',
'DATE' => $this->settings['clock_date'] ? $this->settings['clock_date'] : '%d %b %Y',
'SHORT2' => $this->settings['clock_short2'] ? $this->settings['clock_short2'] : '%d %B %G',
'SHORT2' => $this->settings['clock_short2'] ? $this->settings['clock_short2'] : '%d %B %Y',
'TIME' => 'h:i A',
'ACP' => '%d %B %Y, %H:%M',
'ACP2' => '%d %B %Y, %H:%M',
@@ -215,6 +226,10 @@ class class_localization
{
if( $this->memberData['member_id'] )
{
/* Rest variables to prevent loop when this class is next constructed */
unset( ipsRegistry::$request['langid'] );
unset( ipsRegistry::$request['setlanguage'] );
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'language' => $data['lang_id'] ) ) );
}
else
@@ -252,7 +267,8 @@ class class_localization
// Set locale
//-----------------------------------------
setlocale( LC_ALL, $this->local );
//setlocale( LC_ALL, $this->local );
IPSLib::setlocale( $this->local );
$this->local_data = localeconv();
//-----------------------------------------
@@ -345,8 +361,20 @@ class class_localization
* @return float
*/
public function formatNumber( $number, $places=0 )
{
return str_replace( 'x', $this->local_data['thousands_sep'], number_format( $number, $places, $this->local_data['decimal_point'], 'x' ) );
{
$placeholders = array('@', '~');
$actual = array($this->local_data['decimal_point'], $this->local_data['thousands_sep']);
// format number with placeholders
$formatted = number_format($number, $places, $placeholders[0], $placeholders[1]);
// replace by localized characters
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
{
return iconv( 'windows-1251', 'utf-8', str_replace($placeholders, $actual, $formatted) );
}
return str_replace($placeholders, $actual, $formatted);
}
/**
@@ -401,6 +429,12 @@ class class_localization
if ( preg_match( "#^manual\{([^\{]+?)\}#i", $method, $match ) )
{
$format = $match[1];
//-----------------------------------------
// Shut off relative dates if using manual{} tag
//-----------------------------------------
$norelative = true;
}
else
{
@@ -444,7 +478,7 @@ class class_localization
return '--';
}
if ($this->offset_set == 0)
if ($this->offset_set == 0 OR ! $this->today_time)
{
// Save redoing this code for each call, only do once per page load
@@ -452,8 +486,8 @@ class class_localization
if ( $this->settings['time_use_relative'] )
{
$this->today_time = gmstrftime('%m,%d,%Y', ( time() + $this->offset ) );
$this->yesterday_time = gmstrftime('%m,%d,%Y', ( ( time() - 86400 ) + $this->offset ) );
$this->today_time = @gmstrftime('%m,%d,%Y', ( time() + $this->offset ) );
$this->yesterday_time = @gmstrftime('%m,%d,%Y', ( ( time() - 86400 ) + $this->offset ) );
}
$this->offset_set = 1;
@@ -513,7 +547,12 @@ class class_localization
}
else
{
return gmstrftime($format, ($date + $this->offset) );
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
{
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
}
return @gmstrftime($format, ($date + $this->offset) );
}
}
@@ -523,13 +562,13 @@ class class_localization
else if ( $this->settings['time_use_relative'] and ( $norelative != 1 ) )
{
$this_time = gmstrftime('%m,%d,%Y', ($date + $this->offset) );
$this_time = @gmstrftime('%m,%d,%Y', ($date + $this->offset) );
//-----------------------------------------
// Use level 2 relative?
//-----------------------------------------
if ( $this->settings['time_use_relative'] == 2 AND ($date < time()) )
if ( $this->settings['time_use_relative'] == 2 AND ($date <= time()) )
{
$diff = time() - $date;
@@ -552,15 +591,20 @@ class class_localization
if ( $this_time == $this->today_time )
{
return str_replace( '{--}', $this->words['time_today'], gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
return str_replace( '{--}', $this->words['time_today'], @gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
}
else if ( $this_time == $this->yesterday_time )
{
return str_replace( '{--}', $this->words['time_yesterday'], gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
return str_replace( '{--}', $this->words['time_yesterday'], @gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
}
else
{
return gmstrftime( $format, ($date + $this->offset) );
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
{
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
}
return @gmstrftime( $format, ($date + $this->offset) );
}
}
@@ -570,7 +614,12 @@ class class_localization
else
{
return gmstrftime($format, ($date + $this->offset) );
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
{
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
}
return @gmstrftime($format, ($date + $this->offset) );
}
}
@@ -594,7 +643,7 @@ class class_localization
$this->offset_set = 1;
}
return gmstrftime($method, ($date + $this->offset) );
return @gmstrftime($method, ($date + $this->offset) );
}
/**
@@ -607,8 +656,11 @@ class class_localization
public function getTimeOffset()
{
$r = 0;
$r = ( ( ($this->memberData['time_offset'] AND $this->memberData['time_offset'] != "" ) OR $this->memberData['time_offset'] === '0' OR $this->memberData['time_offset'] === 0 ) ? $this->memberData['time_offset'] : $this->settings['time_offset'] ) * 3600;
$this->settings['time_offset'] = ( ! empty( $this->settings['time_offset'] ) ) ? $this->settings['time_offset'] : 0;
$this->memberData['time_offset'] = ( isset( $this->memberData['time_offset'] ) ) ? $this->memberData['time_offset'] : null;
$r = ( ( $this->memberData['time_offset'] !== null ) ? $this->memberData['time_offset'] : $this->settings['time_offset'] ) * 3600;
if ( $this->settings['time_adjust'] )
{
@@ -659,9 +711,9 @@ class class_localization
* @return void
*/
public function loadLanguageFile( $load=array(), $app='', $lang='', $forceReload=false )
{
{
$_MASTER2 = IPSDebug::getMemoryDebugFlag();
/* App */
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
$load = ( $load ) ? $load : array();
@@ -681,7 +733,7 @@ class class_localization
}
/* Has the global language file been loaded? */
if ( ! in_array( $global, $this->loaded_lang_files ) AND ( $app == 'core' AND ! in_array( $_global, $load ) ) )
if ( ! in_array( $app . '_' . $global, $this->loaded_lang_files ) AND ( $app == 'core' AND ! in_array( $_global, $load ) ) )
{
$load[] = $global;
}
@@ -691,6 +743,8 @@ class class_localization
if( $this->load_from_db OR $this->_forceEnglish )
{
$_apps = array( 0 => "'" . $app . "'" );
if( is_array( $load ) AND count( $load ) )
{
/* Reformat for query and make sure we're not loading something twice */
@@ -698,13 +752,24 @@ class class_localization
foreach( $load as $l )
{
/* Load global from the core app */
if ( $l == $_global )
{
$_apps[] = "'core'";
}
/* Already loaded? */
if ( ! in_array( $app . $l, $this->loaded_lang_files ) OR $forceReload === TRUE )
if ( ! in_array( $app . '_' . $l, $this->loaded_lang_files ) OR $forceReload === TRUE )
{
/* Reformat */
$_load[] = "'{$l}'";
}
if ( ! count( $_load ) )
{
$_load[] = '\'' . $_global . '\'';
}
/* Add to the loaded array */
$this->loaded_lang_files[] = $app . '_' . $l;
}
@@ -713,7 +778,7 @@ class class_localization
$this->DB->build( array(
'select' => 'word_key, word_default, word_custom',
'from' => 'core_sys_lang_words',
'where' => "lang_id={$this->lang_id} AND word_app='{$app}' AND word_pack IN ( " . implode( ',', $_load ) . " )",
'where' => "lang_id={$this->lang_id} AND word_app IN (" . implode( ',', $_apps ) . ") AND word_pack IN ( " . implode( ',', $_load ) . " )",
) );
$this->DB->execute();
@@ -759,7 +824,7 @@ class class_localization
}
else
{
$errors .= "<li>Missing Language File: " . $_file;
$errors .= "<li>Missing Language File: " . $_file . "</li>";
IPSDebug::setMemoryDebugFlag( "NO SUCH Language File: " . str_replace( IPS_CACHE_PATH, '', $_file ), $_MASTER2 );
}
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* ACP Restrictions
* Last Updated: $Date: 2009-12-01 17:42:17 -0500 (Tue, 01 Dec 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 1st march 2002
* @version $Revision: 5501 $
* @version $Revision: 5713 $
*
*/
File diff suppressed because it is too large. Load diff
@@ -1,401 +1,407 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Facilitates reputation plugins
*
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @link http://www.iinvisionpower.com
* @since Wednesday 14th May 2008 14:00
*/
class classReputationCache
{
/**
* Variable that determines if the reputation system is activated
*
* @access public
* @var boolean
*/
public $rep_system_on;
/**
* Error string
*
* @access public
* @var string
*/
public $error_message;
/**
* CONSTRUCTOR
*
* @access public
* @return void
*/
public function __construct()
{
$this->rep_system_on = ipsRegistry::$settings['reputation_enabled'];
}
/**
* Retuns an array for use in a join statement
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param string [$app] App for this content, by default the current application
* @return array
*/
public function getTotalRatingJoin( $type, $type_id, $app='' )
{
/* Online? */
if( ! $this->rep_system_on )
{
return array();
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
/* Return the join array */
return array(
'select' => 'rep_cache.rep_points',
'from' => array( 'reputation_cache' => 'rep_cache' ),
'where' => "rep_cache.app='{$app}' AND rep_cache.type='{$type}' AND rep_cache.type_id={$type_id}",
'type' => 'left',
);
}
/**
* Retuns an array for use in a join statement
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param string [$app] App for this content, by default the current application
* @return array
*/
public function getUserHasRatedJoin( $type, $type_id, $app='' )
{
/* Online? */
if( ! $this->rep_system_on )
{
return array();
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
/* Return the join array */
return array(
'select' => 'rep_index.rep_rating as has_given_rep',
'from' => array( 'reputation_index' => 'rep_index' ),
'where' => "rep_index.app='{$app}' AND
rep_index.type='{$type}' AND
rep_index.type_id={$type_id} AND
rep_index.member_id=" . ipsRegistry::member()->getProperty( 'member_id' ),
'type' => 'left',
);
}
/**
* Adds a rating to the index and updates caches
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param integer $rating Either 1 or -1
* @param string $message Message associated with this rating
* @param integer $member_id Id of the owner of the content being rated
* @param string [$app] App for this content, by default the current application
* @return bool
*/
public function addRate( $type, $type_id, $rating, $message='', $member_id=0, $app='' )
{
ipsRegistry::instance()->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
/* Online? */
if( ! $this->rep_system_on )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_offline'];
return false;
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
$rating = intval( $rating );
if( ! ipsRegistry::member()->getProperty( 'member_id' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_guest'];
return false;
}
if( $rating != -1 && $rating != 1 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
/* Check the point types */
if( $rating == -1 && ipsRegistry::$settings['reputation_point_types'] == 'positive' )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
if( $rating == 1 && ipsRegistry::$settings['reputation_point_types'] == 'negative' )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
/* Day Cutoff */
$day_cutoff = time() - 86400;
/* Check Max Positive Votes */
if( $rating == 1 )
{
if( intval( ipsRegistry::member()->getProperty( 'g_rep_max_positive' ) ) === 0 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_pos'];
return false;
}
$total = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'count(*) as votes',
'from' => 'reputation_index',
'where' => 'member_id=' . ipsRegistry::member()->getProperty( 'member_id' ) . ' AND rep_rating=1 AND rep_date > ' . $day_cutoff
) );
if( $total['votes'] >= ipsRegistry::member()->getProperty( 'g_rep_max_positive' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_pos'];
return false;
}
}
/* Check Max Negative Votes */
if( $rating == -1 )
{
if( intval( ipsRegistry::member()->getProperty( 'g_rep_max_negative' ) ) === 0 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_neg'];
return false;
}
$total = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'count(*) as votes',
'from' => 'reputation_index',
'where' => 'member_id=' . ipsRegistry::member()->getProperty( 'member_id' ) . ' AND rep_rating=-1 AND rep_date > ' . $day_cutoff
) );
if( $total['votes'] >= ipsRegistry::member()->getProperty( 'g_rep_max_negative' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_neg'];
return false;
}
}
/* If no member id was passted in, we have to query it using the config file */
if( ! $member_id )
{
/* Reputation Config */
if( file_exists( IPSLib::getAppDir( $app ) . '/extensions/reputation.php' ) )
{
require( IPSLib::getAppDir( $app ) . '/extensions/reputation.php' );
}
else
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_config'];
return false;
}
if( ! $rep_author_config[$type]['column'] || ! $rep_author_config[$type]['table'] )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_config'];
return false;
}
/* Query the content author */
$content_author = ipsRegistry::DB()->buildAndFetch( array(
'select' => "{$rep_author_config[$type]['column']} as id",
'from' => $rep_author_config[$type]['table'],
'where' => "{$type}={$type_id}"
) );
$member_id = $content_author['id'];
}
if( ! ipsRegistry::$settings['reputation_can_self_vote'] && $member_id == ipsRegistry::member()->getProperty( 'member_id' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_yourown'];
return false;
}
/* Query the member group */
if( ipsRegistry::$settings['reputation_protected_groups'] )
{
$member_group = ipsRegistry::DB()->buildAndFetch( array( 'select' => 'member_group_id', 'from' => 'members', 'where' => "member_id={$member_id}" ) );
if( in_array( $member_group['member_group_id'], explode( ',', ipsRegistry::$settings['reputation_protected_groups'] ) ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_protected'];
return false;
}
}
/* Build the insert array */
$db_insert = array(
'member_id' => ipsRegistry::member()->getProperty( 'member_id' ),
'app' => $app,
'type' => $type,
'type_id' => $type_id,
'misc' => '',
'rep_date' => time(),
'rep_msg' => $message,
'rep_rating' => $rating,
);
/* Check for existing rating */
$current_rating = ipsRegistry::DB()->buildAndFetch( array(
'select' => '*',
'from' => 'reputation_index',
'where' => "app='{$app}' AND type='{$type}' AND type_id={$type_id} AND member_id=".ipsRegistry::member()->getProperty( 'member_id' ),
) );
/* Insert */
if( $current_rating )
{
//ipsRegistry::DB()->update( 'reputation_index', $db_insert, "app='{$app}' AND type='{$type}' AND type_id={$type_id} AND member_id=".ipsRegistry::member()->getProperty( 'member_id' ) );
}
else
{
ipsRegistry::DB()->insert( 'reputation_index', $db_insert );
}
/* Update type cache */
$this->_updateTypeCache( $app, $type, $type_id, $rating, $current_rating );
/* Get authors current rep */
$author_points = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'pp_reputation_points',
'from' => 'profile_portal',
'where' => "pp_member_id={$member_id}"
) );
/* Figure out new rep */
if( $current_rating['rep_rating'] == -1 )
{
$author_points['pp_reputation_points'] += 1;
}
else if( $current_rating['rep_rating'] == 1 )
{
$author_points['pp_reputation_points'] -= 1;
}
$author_points['pp_reputation_points'] += $rating;
ipsRegistry::DB()->update( 'profile_portal', array( 'pp_reputation_points' => $author_points['pp_reputation_points'] ), "pp_member_id={$member_id}" );
return true;
}
/**
* Returns an array of reputation information based on the points passed in
*
* @access public
* @param integer $points Number of points to base the repuation information on
* @return array 'text' and 'image'
*/
public function getReputation( $points )
{
/* INIT */
$cache = ipsRegistry::cache()->getCache( 'reputation_levels' );
$cache = is_array( $cache ) && count( $cache ) ? $cache : array();
$points = intval( $points );
if( count($cache) AND is_array($cache) )
{
foreach( $cache as $k => $r )
{
if( $r['level_points'] == 0 )
{
if( $points >= 0 && $points < intval( $cache[ $k -1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
else if( $points <= 0 && $points > intval( $cache[ $k + 1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
else if( $points == 0 )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
else if( $r['level_points'] > 0 )
{
if( $points >= intval( $r['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
else
{
if( $points <= intval( $r['level_points'] ) && $points > intval( $cache[ $k + 1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
}
}
/* Return the lowest rep, if we're still here */
$r = array_pop( $cache );
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
/**
* Handles updating and creating new caches
*
* @access private
* @param string $app App for this content
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param integer $rating Either 1 or -1
* @param array $old_record If this is a revote, then this array contains the previous vote
* @return void
*/
private function _updateTypeCache( $app, $type, $type_id, $rating, $old_record )
{
/* Update type cache */
$type_cache = ipsRegistry::DB()->buildAndFetch( array(
'select' => '*',
'from' => 'reputation_cache',
'where' => "app='{$app}' AND type='$type' AND type_id='$type_id'",
) );
/* Update cache */
if( $type_cache )
{
/* Previous rating? */
if( $old_record['rep_rating'] == -1 )
{
$type_cache['rep_points'] += 1;
}
else if( $old_record['rep_rating'] == 1 )
{
$type_cache['rep_points'] -= 1;
}
ipsRegistry::DB()->update( 'reputation_cache', array( 'rep_points' => $type_cache['rep_points'] + $rating ), "app='{$app}' AND type='$type' AND type_id='$type_id'" );
}
/* Insert Cache */
else
{
ipsRegistry::DB()->insert( 'reputation_cache', array( 'app' => $app, 'type' => $type, 'type_id' => $type_id, 'rep_points' => $rating ) );
}
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Facilitates reputation plugins
* Last Updated: $Date: 2010-09-29 20:23:38 -0400 (Wed, 29 Sep 2010) $
* </pre>
*
* @author Joshua Williams <josh@invisionpower.com>
* @package IP.Board
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @link http://www.invisionpower.com
* @since Wednesday 14th May 2008 14:00
*/
class classReputationCache
{
/**
* Variable that determines if the reputation system is activated
*
* @access public
* @var boolean
*/
public $rep_system_on;
/**
* Error string
*
* @access public
* @var string
*/
public $error_message;
/**
* CONSTRUCTOR
*
* @access public
* @return void
*/
public function __construct()
{
$this->rep_system_on = ipsRegistry::$settings['reputation_enabled'];
}
/**
* Retuns an array for use in a join statement
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param string [$app] App for this content, by default the current application
* @return array
*/
public function getTotalRatingJoin( $type, $type_id, $app='' )
{
/* Online? */
if( ! $this->rep_system_on )
{
return array();
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
/* Return the join array */
return array(
'select' => 'rep_cache.rep_points',
'from' => array( 'reputation_cache' => 'rep_cache' ),
'where' => "rep_cache.app='{$app}' AND rep_cache.type='{$type}' AND rep_cache.type_id={$type_id}",
'type' => 'left',
);
}
/**
* Retuns an array for use in a join statement
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param string [$app] App for this content, by default the current application
* @return array
*/
public function getUserHasRatedJoin( $type, $type_id, $app='' )
{
/* Online? */
if( ! $this->rep_system_on )
{
return array();
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
/* Return the join array */
return array(
'select' => 'rep_index.rep_rating as has_given_rep',
'from' => array( 'reputation_index' => 'rep_index' ),
'where' => "rep_index.app='{$app}' AND
rep_index.type='{$type}' AND
rep_index.type_id={$type_id} AND
rep_index.member_id=" . ipsRegistry::member()->getProperty( 'member_id' ),
'type' => 'left',
);
}
/**
* Adds a rating to the index and updates caches
*
* @access public
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param integer $rating Either 1 or -1
* @param string $message Message associated with this rating
* @param integer $member_id Id of the owner of the content being rated
* @param string [$app] App for this content, by default the current application
* @return bool
*/
public function addRate( $type, $type_id, $rating, $message='', $member_id=0, $app='' )
{
ipsRegistry::instance()->getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
/* Online? */
if( ! $this->rep_system_on )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_offline'];
return false;
}
/* INIT */
$app = ( $app ) ? $app : ipsRegistry::$current_application;
$rating = intval( $rating );
if( ! ipsRegistry::member()->getProperty( 'member_id' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_guest'];
return false;
}
if( $rating != -1 && $rating != 1 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
/* Check the point types */
if( $rating == -1 && ipsRegistry::$settings['reputation_point_types'] == 'positive' )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
if( $rating == 1 && ipsRegistry::$settings['reputation_point_types'] == 'negative' )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_invalid'];
return false;
}
/* Day Cutoff */
$day_cutoff = time() - 86400;
/* Check Max Positive Votes */
if( $rating == 1 )
{
if( intval( ipsRegistry::member()->getProperty( 'g_rep_max_positive' ) ) === 0 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_pos'];
return false;
}
$total = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'count(*) as votes',
'from' => 'reputation_index',
'where' => 'member_id=' . ipsRegistry::member()->getProperty( 'member_id' ) . ' AND rep_rating=1 AND rep_date > ' . $day_cutoff
) );
if( $total['votes'] >= ipsRegistry::member()->getProperty( 'g_rep_max_positive' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_pos'];
return false;
}
}
/* Check Max Negative Votes */
if( $rating == -1 )
{
if( intval( ipsRegistry::member()->getProperty( 'g_rep_max_negative' ) ) === 0 )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_neg'];
return false;
}
$total = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'count(*) as votes',
'from' => 'reputation_index',
'where' => 'member_id=' . ipsRegistry::member()->getProperty( 'member_id' ) . ' AND rep_rating=-1 AND rep_date > ' . $day_cutoff
) );
if( $total['votes'] >= ipsRegistry::member()->getProperty( 'g_rep_max_negative' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_quota_neg'];
return false;
}
}
/* If no member id was passted in, we have to query it using the config file */
if( ! $member_id )
{
/* Reputation Config */
if( file_exists( IPSLib::getAppDir( $app ) . '/extensions/reputation.php' ) )
{
$rep_author_config = array();
require( IPSLib::getAppDir( $app ) . '/extensions/reputation.php' );
}
else
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_config'];
return false;
}
if( ! $rep_author_config[$type]['column'] || ! $rep_author_config[$type]['table'] )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_config'];
return false;
}
/* Query the content author */
$content_author = ipsRegistry::DB()->buildAndFetch( array(
'select' => "{$rep_author_config[$type]['column']} as id",
'from' => $rep_author_config[$type]['table'],
'where' => "{$type}={$type_id}"
) );
$member_id = $content_author['id'];
}
if( ! ipsRegistry::$settings['reputation_can_self_vote'] && $member_id == ipsRegistry::member()->getProperty( 'member_id' ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_yourown'];
return false;
}
/* Query the member group */
if( ipsRegistry::$settings['reputation_protected_groups'] )
{
$member_group = ipsRegistry::DB()->buildAndFetch( array( 'select' => 'member_group_id', 'from' => 'members', 'where' => "member_id={$member_id}" ) );
if( in_array( $member_group['member_group_id'], explode( ',', ipsRegistry::$settings['reputation_protected_groups'] ) ) )
{
$this->error_message = ipsRegistry::instance()->getClass( 'class_localization' )->words['reputation_protected'];
return false;
}
}
/* Build the insert array */
$db_insert = array(
'member_id' => ipsRegistry::member()->getProperty( 'member_id' ),
'app' => $app,
'type' => $type,
'type_id' => $type_id,
'rep_date' => time(),
'rep_msg' => $message,
'rep_rating' => $rating,
);
/* Check for existing rating */
$current_rating = ipsRegistry::DB()->buildAndFetch( array(
'select' => '*',
'from' => 'reputation_index',
'where' => "app='{$app}' AND type='{$type}' AND type_id={$type_id} AND member_id=".ipsRegistry::member()->getProperty( 'member_id' ),
) );
/* Insert */
if( $current_rating )
{
//ipsRegistry::DB()->update( 'reputation_index', $db_insert, "app='{$app}' AND type='{$type}' AND type_id={$type_id} AND member_id=".ipsRegistry::member()->getProperty( 'member_id' ) );
return true;
}
else
{
ipsRegistry::DB()->insert( 'reputation_index', $db_insert );
}
/* Update type cache */
$this->_updateTypeCache( $app, $type, $type_id, $rating, $current_rating );
/* Get authors current rep */
$author_points = ipsRegistry::DB()->buildAndFetch( array(
'select' => 'pp_reputation_points',
'from' => 'profile_portal',
'where' => "pp_member_id={$member_id}"
) );
/* Figure out new rep */
if( $current_rating['rep_rating'] == -1 )
{
$author_points['pp_reputation_points'] += 1;
}
else if( $current_rating['rep_rating'] == 1 )
{
$author_points['pp_reputation_points'] -= 1;
}
$author_points['pp_reputation_points'] += $rating;
ipsRegistry::DB()->update( 'profile_portal', array( 'pp_reputation_points' => $author_points['pp_reputation_points'] ), "pp_member_id={$member_id}" );
return true;
}
/**
* Returns an array of reputation information based on the points passed in
*
* @access public
* @param integer $points Number of points to base the repuation information on
* @return array 'text' and 'image'
*/
public function getReputation( $points )
{
/* INIT */
$cache = ipsRegistry::cache()->getCache( 'reputation_levels' );
$cache = is_array( $cache ) && count( $cache ) ? $cache : array();
$points = intval( $points );
if( count($cache) AND is_array($cache) )
{
foreach( $cache as $k => $r )
{
if( $r['level_points'] == 0 )
{
if( $points >= 0 && $points < intval( $cache[ $k -1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
else if( $points <= 0 && $points > intval( $cache[ $k + 1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
else if( $points == 0 )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
else if( $r['level_points'] > 0 )
{
if( $points >= intval( $r['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
else
{
if( $points <= intval( $r['level_points'] ) && $points > intval( $cache[ $k + 1 ]['level_points'] ) )
{
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
}
}
}
/* Return the lowest rep, if we're still here */
$r = array_pop( $cache );
return array( 'text' => $r['level_title'], 'image' => $r['level_image'] ? ipsRegistry::$settings['public_dir'] . 'style_extra/reputation_icons/' . $r['level_image'] : '' );
}
/**
* Handles updating and creating new caches
*
* @access private
* @param string $app App for this content
* @param string $type Type of content, ex; Post
* @param integer $type_id ID of the type, ex: pid
* @param integer $rating Either 1 or -1
* @param array $old_record If this is a revote, then this array contains the previous vote
* @return void
*/
private function _updateTypeCache( $app, $type, $type_id, $rating, $old_record )
{
/* Update type cache */
$type_cache = ipsRegistry::DB()->buildAndFetch( array(
'select' => '*',
'from' => 'reputation_cache',
'where' => "app='{$app}' AND type='$type' AND type_id='$type_id'",
) );
/* Update cache */
if( $type_cache )
{
/* Previous rating? */
if( $old_record['rep_rating'] == -1 )
{
$type_cache['rep_points'] += 1;
}
else if( $old_record['rep_rating'] == 1 )
{
$type_cache['rep_points'] -= 1;
}
ipsRegistry::DB()->update( 'reputation_cache', array( 'rep_points' => $type_cache['rep_points'] + $rating ), "app='{$app}' AND type='$type' AND type_id='$type_id'" );
}
/* Insert Cache */
else
{
ipsRegistry::DB()->insert( 'reputation_cache', array( 'app' => $app, 'type' => $type, 'type_id' => $type_id, 'rep_points' => $rating ) );
}
}
}
@@ -1,16 +1,19 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Task Manager Library
* Last Updated: $Date: 2010-08-30 19:21:56 -0400 (Mon, 30 Aug 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @version $Rev: 5518 $
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 6810 $
*
*/
@@ -164,11 +167,8 @@ class class_taskmanager
$this->saveNextRunStamp();
}
# Cancel and return if not forcing the key
if ( ! defined( 'FORCE_TASK_KEY' ) )
{
return;
}
# Cancel and return if locked
return;
}
//-----------------------------------------
@@ -345,14 +345,22 @@ class class_taskmanager
break;
}
}
//-----------------------------------------
// Sort out the hour...
//-----------------------------------------
if ( $task['task_hour'] == -1)
{
$this->run_hour = $this->date_now['hour'];
/* If week, month are -1 and min =0 then on the hour, otherwise: */
if ( ! $day_set AND $task['task_minute'] == 0 )
{
$this->_addHour( 1 );
}
else
{
$this->run_hour = $this->date_now['hour'];
}
}
else
{
@@ -458,7 +466,7 @@ class class_taskmanager
//-----------------------------------------
$next_run = gmmktime( $this->run_hour, $this->run_minute, 0, $this->run_month, $this->run_day, $this->run_year );
return $next_run;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,15 +1,18 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Custom Profile Fields
* Last Updated: $Date: 2009-11-13 19:55:00 -0500 (Fri, 13 Nov 2009) $
* Last Updated: $Date: 2010-09-27 18:18:35 -0400 (Mon, 27 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @link http://www.iinvisionpower.com
* @version $Rev: 5405 $
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 6917 $
*
*/
@@ -24,7 +27,6 @@ class customProfileFields
/**
* Member ID
*
* @access public
* @var int
*/
public $member_id = 0;
@@ -32,7 +34,6 @@ class customProfileFields
/**
* Member ID
*
* @access public
* @var int
*/
public $mem_data_id = 0;
@@ -40,7 +41,6 @@ class customProfileFields
/**
* Array of incoming data
*
* @access public
* @var array
*/
public $in_fields = array();
@@ -48,7 +48,6 @@ class customProfileFields
/**
* Final/parsed data
*
* @access public
* @var array
*/
public $out_fields = array();
@@ -56,7 +55,6 @@ class customProfileFields
/**
* Chosen output data
*
* @access public
* @var array
*/
public $out_chosen = array();
@@ -64,7 +62,6 @@ class customProfileFields
/**
* Member record
*
* @access public
* @var array
*/
public $member_data = array();
@@ -72,7 +69,6 @@ class customProfileFields
/**
* Field names
*
* @access public
* @var array
*/
public $field_names = array();
@@ -80,7 +76,6 @@ class customProfileFields
/**
* Field descriptions
*
* @access public
* @var array
*/
public $field_desc = array();
@@ -88,7 +83,6 @@ class customProfileFields
/**
* Error fields
*
* @access public
* @var array
*/
public $error_fields = array();
@@ -96,7 +90,6 @@ class customProfileFields
/**
* Error messages
*
* @access public
* @var array
*/
public $error_messages = array();
@@ -104,7 +97,6 @@ class customProfileFields
/**
* What type of parse this is
*
* @access public
* @var string
*/
public $type = '';
@@ -112,7 +104,6 @@ class customProfileFields
/**
* Is an admin
*
* @access public
* @var bool
*/
public $admin = false;
@@ -120,7 +111,6 @@ class customProfileFields
/**
* Is an admin
*
* @access public
* @var bool
*/
public $supmod = false;
@@ -128,7 +118,6 @@ class customProfileFields
/**
* Initialized yet
*
* @access public
* @var bool
*/
public $init = false;
@@ -136,7 +125,6 @@ class customProfileFields
/**
* Cache data
*
* @access public
* @var array
*/
public $cache_data = array();
@@ -144,7 +132,6 @@ class customProfileFields
/**
* Custom fields library
*
* @access public
* @var object
*/
public $cfields;
@@ -152,7 +139,6 @@ class customProfileFields
/**
* Skin group to use for view parsing
*
* @access public
* @var string
*/
public $skinGroup = '';
@@ -160,24 +146,21 @@ class customProfileFields
/**
* Database handle
*
* @access private
* @var object
*/
private $DB;
protected $DB;
/**
* Already added fields
* Prevents MSSQL getting confused
*
* @access private
* @var array
*/
private $_addedFields = array();
protected $_addedFields = array();
/**
* CONSTRUCTOR
*
* @access public
* @return void
*/
public function __construct()
@@ -195,7 +178,6 @@ class customProfileFields
/**
* Initializes cache, loads kernel class, and formats data for kernel class
*
* @access public
* @param string $type Set to view for displaying the field normally or edit for displaying in a form
* @param bool $mlist Whether this is the memberlist or not
* @return void
@@ -248,11 +230,11 @@ class customProfileFields
if( $mlist )
{
$this->in_fields[ $id ] = ipsRegistry::$request[ 'field_' . $id ];
$this->in_fields[ $id ] = ( isset(ipsRegistry::$request[ 'field_' . $id ]) AND ipsRegistry::$request[ 'field_' . $id ] ) ? ipsRegistry::$request[ 'field_' . $id ] : '';
}
else
{
$this->in_fields[ $id ] = isset( $this->member_data['field_'.$id] ) ? $this->member_data['field_' . $id] : ipsRegistry::$request[ 'field_' . $id ];
$this->in_fields[ $id ] = isset( $this->member_data['field_'.$id] ) ? $this->member_data['field_' . $id] : ( isset(ipsRegistry::$request[ 'field_' . $id ]) ? ipsRegistry::$request[ 'field_' . $id ] : '' );
}
}
}
@@ -279,10 +261,11 @@ class customProfileFields
/* Field Restrictions */
$this->cache_data[$k]['restrictions'] = array(
'max_size' => isset( $v['pf_max_input'] ) ? $v['pf_max_input'] : '',
'min_size' => isset( $v['pf_min_input'] ) ? $v['pf_min_input'] : '',
'not_null' => isset( $v['pf_not_null'] ) ? $v['pf_not_null'] : '',
'format' => isset( $v['pf_input_format'] ) ? $v['pf_input_format'] : '',
'max_size' => isset( $v['pf_max_input'] ) ? $v['pf_max_input'] : '',
'min_size' => isset( $v['pf_min_input'] ) ? $v['pf_min_input'] : '',
'not_null' => isset( $v['pf_not_null'] ) ? $v['pf_not_null'] : '',
'format' => isset( $v['pf_input_format'] ) ? $v['pf_input_format'] : '',
'urlfilter' => isset( $v['pf_filtering'] ) ? $v['pf_filtering'] : '',
);
}
@@ -299,7 +282,6 @@ class customProfileFields
/**
* Parses fields for saving into the database, results are stored in $this->out_fields
*
* @access public
* @param array $field_data Array that contains the fields to parse, usually $this->request
* @return void
*/
@@ -315,7 +297,7 @@ class customProfileFields
if( is_array( $this->error_fields ) && count( $this->error_fields ) )
{
/* Make sure error message texts are loaded */
ipsRegistry::getClass( 'class_localization' )->loadLanguageFile( array( 'public_profile' ), 'members' );
ipsRegistry::getClass( 'class_localization' )->loadLanguageFile( array( 'public_profile' ), 'members' );
foreach( $this->error_fields as $id => $err )
{
@@ -342,7 +324,7 @@ class customProfileFields
/* Can we view this field? */
if( ! $this->_checkFieldAuth( $field, $mode ) )
{
continue;
continue;
}
/* Now add any missing content fields */
@@ -357,13 +339,34 @@ class customProfileFields
}
$this->out_fields[ 'field_' . $id ] = IPSText::getTextClass( 'bbcode' )->stripBadWords( $save_fields['save_array']['field_' . $id] );
//-----------------------------------------
// Blacklisted urls
// @link http://community.invisionpower.com/tracker/issue-7872-url-black-list-in-profile/
//-----------------------------------------
if( $this->cache_data[$id]['restrictions']['urlfilter'] AND !IPSText::getTextClass( 'bbcode' )->checkBlacklistUrls( $save_fields['save_array']['field_' . $id] ) )
{
/* Make sure error message texts are loaded */
ipsRegistry::getClass( 'class_localization' )->loadLanguageFile( array( 'public_profile' ), 'members' );
if( array_key_exists( 'field_' . $id, $this->error_messages ) )
{
$this->error_messages['field_' . $id] .= ', ' . ipsRegistry::getClass( 'class_localization' )->words['profile_field_error__blacklist'];
}
else
{
$this->error_messages['field_' . $id] = $this->cache_data[ $id ]['pf_title'] . ': ' . ipsRegistry::getClass( 'class_localization' )->words['profile_field_error__blacklist'];
}
}
}
//print_r($this->error_messages);
}
/**
* Parses fields for viewing, results are stored in $this->out_fields
*
* @access public
* @param bool $check_topic_format Whether to apply topic formatting
* @param string $location Location being called from
* @return void
@@ -446,7 +449,6 @@ class customProfileFields
/**
* Fetch group keys and titles
*
* @access public
* @return array array( pf_group_key => pf_group_name )
*/
public function fetchGroupTitles()
@@ -471,7 +473,6 @@ class customProfileFields
/**
* Parses fields for editing, results are stored in $this->out_fields
*
* @access public
* @param string [$mode] register or normal, normal is default
* @return void
*/
@@ -499,12 +500,11 @@ class customProfileFields
/**
* Checks to see if the field is viewable by the current user
*
* @access private
* @param array $field Array of field data
* @param string $mode Register, or blank
* @return bool
*/
private function _checkFieldAuth( $field, $mode='normal' )
protected function _checkFieldAuth( $field, $mode='normal' )
{
/* Admin / mod only? */
if( $field->raw_data['pf_admin_only'] )
@@ -521,11 +521,11 @@ class customProfileFields
if ( $mode != 'register' AND ! $this->admin AND !$this->supmod )
{
return false;
}
}
}
/* Registering */
if ( $mode == 'register' AND ! $field->raw_data['pf_show_on_reg'] )
if ( $mode == 'register' AND ! $field->raw_data['pf_show_on_reg'] AND ! IN_ACP ) // Bug Fix #21163
{
return false;
}
@@ -557,8 +557,8 @@ class customProfileFields
return false;
}
}
return true;
return true;
}
/**
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Editor Library: Core Class
* Last Updated: $Date: 2009-10-01 16:51:20 -0400 (Thu, 01 Oct 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5194 $
* @version $Revision: 5713 $
*
* EXAMPLE USAGE
* <code>
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Editor Library: RTE (WYSIWYG) Class
* Last Updated: $Date: 2009-11-13 19:55:00 -0500 (Fri, 13 Nov 2009) $
* Last Updated: $Date: 2010-11-15 11:39:10 -0500 (Mon, 15 Nov 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5405 $
* @version $Revision: 7185 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -107,7 +109,7 @@ class class_editor_module extends class_editor
// Trim
//-----------------------------------------
$t = trim($t);
$t = rtrim($t);
//-------------------------------
// Convert all types of single quotes
@@ -150,7 +152,8 @@ class class_editor_module extends class_editor
$t = str_ireplace( "<br />\r\n", "<br />", $t );
$t = str_ireplace( "<br />\n", "<br />", $t );
$t = str_ireplace( "<br />\r", "<br />", $t );
$t = preg_replace( "/((?:\r)?\n?(?:\s)+)/u", " ", $t );
//$t = preg_replace( "/((?:\r)?\n?(?:[\r|\n|\t| ])+)/", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/u", " ", $t );
}
else
@@ -206,7 +209,7 @@ class class_editor_module extends class_editor
//-----------------------------------------
$t = str_replace( " ", "&nbsp;&nbsp;", $t );
return $t;
}
@@ -222,7 +225,7 @@ class class_editor_module extends class_editor
//-----------------------------------------
// INIT
//-----------------------------------------
$tag = $matches[1];
$txt = $matches[2];
@@ -249,9 +252,9 @@ class class_editor_module extends class_editor
* @param string Form field name OR Raw text
* @return string Text ready for editor
*/
public function processAfterForm( $form_field )
public function processAfterForm( $form_field, $isDefinitelyFullText=false )
{
$t = isset( $_POST[ $form_field ] ) ? IPSText::stripslashes($_POST[ $form_field ]) : $form_field;
$t = ( $isDefinitelyFullText ) ? $form_field : ( isset( $_POST[ $form_field ] ) ? IPSText::stripslashes($_POST[ $form_field ]) : $form_field );
$ot = $t;
//print $t;
@@ -265,7 +268,7 @@ class class_editor_module extends class_editor
$t = str_replace( '&nbsp;&nbsp;&nbsp; ', "{'tab'}", $t );
$t = str_replace( '&nbsp;', ' ', $t );
//print htmlspecialchars($t);print "<br><br><br>---------------------<br><br><br>";
//-----------------------------------------
// Fix up lines for safari...
//-----------------------------------------
@@ -290,7 +293,8 @@ class class_editor_module extends class_editor
$t = str_ireplace( "<br />\r\n", "<br />", $t );
$t = str_ireplace( "<br />\n", "<br />", $t );
$t = str_ireplace( "<br />\r", "<br />", $t );
$t = preg_replace( "/((?:\r)?\n?(?:\s)+)/u", " ", $t );
//$t = preg_replace( "/((?:\r)?\n?(?:[\r|\n|\t| ])+)/", " ", $t );
$t = preg_replace( "/((?:\r)?\n+)/u", " ", $t );
}
else
@@ -315,8 +319,11 @@ class class_editor_module extends class_editor
// Fix up incorrectly nested urls / BBcode
//-----------------------------------------
// @link http://community.invisionpower.com/tracker/issue-24704-pasting-content-in-rte-with-image-first/
// Revert the fix for now as it causes more issues than the original one
$t = preg_replace( '#<a\s+?href=[\'"]([^>]+?)\[(.+?)[\'"](.+?)'.'>(.+?)\[\\2</a>#is', '<a href="\\1"\\3>\\4</a>[\\2', $t );
//$t = preg_replace( '#<a\s+?href=[\'"]([^>\'"]+?)[\'"](.*?)>(.+?)\[([^<]+?)</a>#is', '<a href="\\1">\\3</a>[\\4', $t );
//-----------------------------------------
// Make URLs safe (prevent tag stripping)
//-----------------------------------------
@@ -380,6 +387,16 @@ class class_editor_module extends class_editor
$t = preg_replace( "#<font (color|size|face)=\"([a-zA-Z0-9\s\#\-]*?)\">(\s*)</font>#is", " ", $t );
//-----------------------------------------
// WYSI-Weirdness #5a: Fix up smilies: IE RTE
// @see Ticket 623146
//-----------------------------------------
$t = preg_replace( "#<img class=(\S+?) alt=(\S+?) src=[\"'](.+?)[\"']>#i", "<img src='\\3' class='\\1' alt='\\2' />", $t );
$t = preg_replace( "#alt='[\"'](\S+?)['\"]'#i", "alt='\\1'", $t );
$t = preg_replace( "#class='[\"'](\S+?)['\"]'#i", "class='\\1'", $t );
$t = preg_replace( "#([a-zA-Z0-9])<img src=[\"'](.+?)[\"'] class=[\"'](.+?)[\"'] alt=[\"'](.+?)[\"'] />#i", "\\1 <img src='\\2' class='\\3' alt='\\4' />", $t );
//-----------------------------------------
// WYSI-Weirdness #5: Fix up smilies
//-----------------------------------------
@@ -395,6 +412,7 @@ class class_editor_module extends class_editor
// WYSI-Weirdness #6: Image tags
//-----------------------------------------
$t = preg_replace( "#<img alt=[\"'][\"'] height=[\"']\d+?[\"'] width=[\"']\d+?[\"']\s+?/>#", "", $t );
$t = preg_replace( "#<img.+?src=[\"'](.+?)[\"']([^>]+?)?".">#is", "[img]\\1[/img]", $t );
//-----------------------------------------
@@ -515,7 +533,7 @@ class class_editor_module extends class_editor
//-----------------------------------------
$t = $this->_cleanPost( $t );
//print htmlspecialchars($t);exit;
//-----------------------------------------
// Debug?
//-----------------------------------------
@@ -961,7 +979,7 @@ class class_editor_module extends class_editor
//-----------------------------------------
// Start the loop
//-----------------------------------------
while ( $tag_begin_loc !== FALSE )
{
$lowtext = mb_strtolower($text);
@@ -1194,6 +1212,7 @@ class class_editor_module extends class_editor
break;
case 'font-size: xxx-large;':
case 'font-size: -webkit-xxx-large;':
$matches[3] = 'font-size: 36;';
break;
}
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Editor Library: Standard Class
* Last Updated: $Date: 2009-02-04 15:03:36 -0500 (Wed, 04 Feb 2009) $
* Last Updated: $Date: 2010-05-25 10:50:21 -0400 (Tue, 25 May 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 3887 $
* @version $Revision: 6387 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -46,9 +48,9 @@ class class_editor_module extends class_editor
* @param string Form field name OR Raw text
* @return string Text ready for editor
*/
public function processAfterForm( $form_field )
public function processAfterForm( $form_field, $isDefinitelyFullText=false )
{
$content = isset( $_POST[ $form_field ] ) ? $_POST[ $form_field ] : $form_field;
$content = ( $isDefinitelyFullText ) ? $form_field : ( isset( $_POST[ $form_field ] ) ? $_POST[ $form_field ] : $form_field );
return $this->_cleanPost( trim($content) );
}
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Item Marking
* Owner: Matt "Oh Lord, why did I get assigned this?" Mecham
* Last Updated: $Date: 2009-12-07 08:17:42 -0500 (Mon, 07 Dec 2009) $
* Last Updated: $Date: 2010-10-06 06:09:32 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5523 $
* @version $Revision: 6946 $
*
* @todo [Future] Perhaps find more ways to reduce the size of items_read
* @todo [Future] Maybe add an IN_DEV tool to warn when markers have been cancelled out / size drastically reduced
@@ -150,6 +152,8 @@ class classItemMarking
*/
private $_noGuestMarking = false;
private $_setSaveCookie = false;
/**
* Method constructor
*
@@ -383,6 +387,35 @@ class classItemMarking
}
}
/**
* Public method to get cookie
*
* @access public
* @param string APP
* @param string Type of key (items, read)
* @return mixed
*/
public function fetchCookieData( $app, $type )
{
if ( $app )
{
$key = ( $type != 'items' ) ? 'itemMarking_' . $app : 'itemMarking_' . $app . '_items';
return $this->_fetchCookieData( $key );
}
}
/**
* Set the flag to save cookies in mydestruct
*
* @access protected
* @return void
*/
protected function _setSaveCookie()
{
$this->_setSaveCookie = true;
}
/**
* Save cookie
*
@@ -396,7 +429,7 @@ class classItemMarking
{
return;
}
if ( $key AND is_array( $this->_cookie[ $key ] ) )
{
IPSCookie::set( $key, $this->_cookie[ $key ], 1 );
@@ -434,7 +467,7 @@ class classItemMarking
*
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
*
* @example $read = $itemMarking->isRead( array( 'forumID' => 2, 'itemID' => 99, 'itemLastUpdate' => 1989098989 ) );
* <code>$read = $itemMarking->isRead( array( 'forumID' => 2, 'itemID' => 99, 'itemLastUpdate' => 1989098989 ) );</code>
*
* @access public
* @param array Array of data
@@ -489,8 +522,8 @@ class classItemMarking
*
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
*
* @example $itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) )
* @example $itemMarking->markAsRead( array( 'forumID' => 34 ) )
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) );</code>
* <code>$itemMarking->markAsRead( array( 'forumID' => 34 ) );</code>
*
* @access public
* @param array
@@ -545,36 +578,45 @@ class classItemMarking
}
/* Overwrite read items */
$_readItems = $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'];
if ( is_array( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] ) )
{
foreach( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] as $i => $d )
{
$_readItems[ $i ] = $d;
}
}
}
/* Check last reset time */
$_lastReset = IPSLib::fetchHighestNumber( array( $_cookieGreset, isset( $cookie['global']) ? $cookie['global'] : 0, intval( $this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] ) ) );
/* Fetch unread items */
$_unreadCount = $this->_fetchModule( $app )->fetchUnreadCount( $origData, $_readItems, $_lastReset );
if ( $_unreadCount['count'] > 0 )
if ( $this->settings['topic_marking_enable'] OR ( ! $this->settings['topic_marking_enable'] AND ! $this->settings['topic_marking_noquery'] ) )
{
if ( $this->settings['topic_marking_enable'] )
$_unreadCount = $this->_fetchModule( $app )->fetchUnreadCount( $origData, $_readItems, $_lastReset );
if ( $_unreadCount['count'] > 0 )
{
$this->_itemMarkers[ $app ][ $mainKey ]['item_unread_count'] = $_unreadCount['count'];
if ( $this->settings['topic_marking_enable'] )
{
$this->_itemMarkers[ $app ][ $mainKey ]['item_unread_count'] = $_unreadCount['count'];
}
}
}
else
{
if ( $this->settings['topic_marking_enable'] )
else
{
/* Update the last global reset time and clear the read array */
$this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] = array();
$this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] = time();
$this->_itemMarkers[ $app ][ $mainKey ]['item_unread_count'] = 0;
if ( $this->settings['topic_marking_enable'] )
{
/* Update the last global reset time and clear the read array */
$this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] = array();
$this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] = time();
$this->_itemMarkers[ $app ][ $mainKey ]['item_unread_count'] = 0;
}
/* Cookie */
$cookie['greset'][ $this->_makeKey( $data, TRUE ) ] = time();
$this->_updateCookieData( 'itemMarking_' . $app, $cookie );
$this->_updateCookieData( 'itemMarking_' . $app . '_items', array() );
}
/* Cookie */
$cookie['greset'][ $this->_makeKey( $data, TRUE ) ] = time();
$this->_updateCookieData( 'itemMarking_' . $app, $cookie );
$this->_updateCookieData( 'itemMarking_' . $app . '_items', array() );
}
}
else
@@ -597,7 +639,7 @@ class classItemMarking
$this->_itemMarkers[ $app ][ $mainKey ]['item_last_update'] = time();
/* Save cookie */
$this->_saveCookie();
$this->_setSaveCookie();
/* Save markers */
if ( $this->fetchInstantSaveStatus() )
@@ -637,8 +679,8 @@ class classItemMarking
/* Reset member cache */
IPSMember::packMemberCache( $this->memberData['member_id'], array('gb_mark__' . $app => time() ) );
/* Delete permanent rows */
$this->DB->delete( 'core_item_markers', "item_app='" . $app . "' AND item_member_id=" . intval( $this->memberData['member_id'] ) );
/* Mark rows for deletion */
$this->DB->update( 'core_item_markers', array( 'item_is_deleted' => 1 ), "item_app='" . $app . "' AND item_member_id=" . intval( $this->memberData['member_id'] ) );
/* Update the last global reset time and clear the read array */
$this->_itemMarkers[ $app ][ $_key ]['item_read_array'] = array();
@@ -661,8 +703,27 @@ class classItemMarking
/* Do 'em all */
$cache = array();
/* Bug #23130 If DB marking is off, _itemMarkers is empty, so we just assume forums */
if ( ! count( $this->_itemMarkers ) )
{
$this->_itemMarkers = array( 'forums' => array() );
}
foreach( $this->_itemMarkers as $app => $data )
{
/* Only process is the app actually does topic marking */
$f = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
if ( file_exists( $f ) )
{
require_once( $f );
if ( ! @class_exists( 'itemMarking__' . $app ) )
{
continue;
}
}
$cache[ 'gb_mark__' . $app ] = time();
/* Update cookies */
@@ -679,8 +740,8 @@ class classItemMarking
/* Delete temporary storage */
$this->DB->delete( 'core_item_markers_storage', 'item_member_id=' . intval( $this->memberData['member_id'] ) );
/* Delete permanent rows */
$this->DB->delete( 'core_item_markers', "item_member_id=" . intval( $this->memberData['member_id'] ) );
/* Mark rows for deletion */
$this->DB->update( 'core_item_markers', array( 'item_is_deleted' => 1 ), 'item_member_id=' . intval( $this->memberData['member_id'] ) );
/* Reset internal array */
$this->_itemMarkers = array();
@@ -690,7 +751,7 @@ class classItemMarking
}
/* Save cookie */
$this->_saveCookie();
$this->_setSaveCookie();
}
/**
@@ -750,17 +811,62 @@ class classItemMarking
return 0;
}
/**
* Fetches the oldest unread timestamp
*
* In this example we are retrieving the number of unread items for a forum id 2
* $unreadCount = $this->fetchOldestUnreadTimestamp( array( 'forumID' => 2 ) );
*
* @access public
* @param array Data
* @param string App
* @return int Number of unread items left
*/
public function fetchOldestUnreadTimestamp( $data, $app='' )
{
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
$data = $this->_fetchModule( $app )->convertData( $data );
$time = IPS_UNIX_TIME_NOW;
if ( ! isset( $data['item_app_key_1'] ) )
{
if ( is_array( $this->_itemMarkers[ $app ] ) AND count( $this->_itemMarkers[ $app ] ) )
{
foreach( $this->_itemMarkers[ $app ] as $key => $_data )
{
if ( $_data['item_global_reset'] && ( $_data['item_global_reset'] < $time ) )
{
$time = $_data['item_global_reset'];
}
}
}
}
else
{
$mainKey = $this->_findMainRowByKey( $data, $app );
$_data = $this->_itemMarkers[ $app ][ $mainKey ];
if ( $_data['item_global_reset'] && ( $_data['item_global_reset'] < $time ) )
{
$time = $_data['item_global_reset'];
}
}
return $time;
}
/**
* Fetch read IDs since last global reset
* Returns IDs read based on incoming data
*
* @example $readIDs = $itemMarking->fetchReadIds( array( 'forumID' => 2 ) );
* <code>$readIDs = $itemMarking->fetchReadIds( array( 'forumID' => 2 ) );</code>
* @access public
* @param array Array of data
* @param strng [App]
* @return array Array of read item IDs
*/
public function fetchReadIds( $data, $app='' )
public function fetchReadIds( $data, $app='', $keysOnly=true )
{
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
$origData = $data;
@@ -769,7 +875,7 @@ class classItemMarking
if ( isset( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] ) AND is_array($this->_itemMarkers[ $app ][ $mainKey ]['item_read_array']) )
{
return array_keys( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] );
return ( $keysOnly ) ? array_keys( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] ) : $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'];
}
else
{
@@ -777,6 +883,32 @@ class classItemMarking
}
}
/**
* Fetch read ID
* If forum was cleared, it may not exist as global reset takes precidence.
* <code>$readIDs = $itemMarking->fetchReadId( array( 'forumID' => 2, 'itemId' => 2 ) );</code>
* @access public
* @param array Array of data
* @param strng [App]
* @return int 0 or timestamp
*/
public function fetchItemReadTime( $data, $app='' )
{
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
$origData = $data;
$data = $this->_fetchModule( $app )->convertData( $data );
$mainKey = $this->_findMainRowByKey( $data, $app );
if ( isset( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'] ) AND is_array($this->_itemMarkers[ $app ][ $mainKey ]['item_read_array']) )
{
return intval( $this->_itemMarkers[ $app ][ $mainKey ]['item_read_array'][ $data['itemID'] ] );
}
else
{
return 0;
}
}
/**
* Save my markers to DB
*
@@ -784,6 +916,7 @@ class classItemMarking
*
* @access public
* @return int Number of rows saved
* @deprecated 3.1.0
*/
public function writeMyMarkersToDB()
{
@@ -819,7 +952,7 @@ class classItemMarking
}
/**
* Find latest Global reset
* Find latest Item reset
*
* @access protected
* @param array Array of data (DB field names)
@@ -882,7 +1015,7 @@ class classItemMarking
}
$mainKey = $this->_findMainRowByKey( $data, $app );
/* Got all fields? */
if ( isset( $this->_itemMarkers[ $app ][ $mainKey ]['item_global_reset'] ) )
{
@@ -925,7 +1058,7 @@ class classItemMarking
$_key = $this->_makeKey( $data );
if ( ! is_array( $this->_itemMarkers[ $app ] ) )
if ( ! isset( $this->_itemMarkers[ $app ] ) OR ! is_array( $this->_itemMarkers[ $app ] ) )
{
/* Mark markers as having changed */
$this->_changesMade = TRUE;
@@ -943,7 +1076,7 @@ class classItemMarking
return $_key;
}
if ( is_array( $this->_itemMarkers[ $app ][ $_key ] ) )
if ( ! empty( $this->_itemMarkers[ $app ][ $_key ] ) AND is_array( $this->_itemMarkers[ $app ][ $_key ] ) )
{
/* Make sure it contains the app & key */
$this->_itemMarkers[ $app ][ $_key ]['item_app'] = $app;
@@ -1167,7 +1300,8 @@ class classItemMarking
'item_last_saved' => time(),
'item_read_array' => ( is_array( $data['item_read_array'] ) ) ? serialize( $data['item_read_array'] ) : $data['item_read_array'],
'item_global_reset' => intval( $data['item_global_reset'] ),
'item_last_update' => intval( $data['item_last_update'] ) );
'item_last_update' => intval( $data['item_last_update'] ),
'item_is_deleted' => 0 );
/* Overwrite $data with the values in $row */
$new_array = array_merge( $data, $row );
@@ -1181,13 +1315,11 @@ class classItemMarking
/* Weed out useless rows */
if ( ! $new_array['item_global_reset'] AND ! $new_array['item_unread_count'] AND ( ! $new_array['item_read_array'] OR $new_array['item_read_array'] == 'a:0:{}' ) )
{
$this->DB->delete( 'core_item_markers', "item_key='{$key}' AND item_app='{$app}' AND item_member_id=" . $memberID );
$new_array['item_is_deleted'] = 1;
IPSDebug::addLogMessage( "Item Markers NOT saved", 'marker_skipped-' . $memberID, $new_array );
}
else
{
$this->DB->replace( 'core_item_markers', $new_array, array( 'item_key', 'item_app', 'item_member_id' ) );
}
$this->DB->replace( 'core_item_markers', $new_array, array( 'item_key', 'item_app', 'item_member_id' ) );
}
}
}
@@ -1221,6 +1353,12 @@ class classItemMarking
return;
}
/* Save cookies */
if ( $this->_setSaveCookie )
{
$this->_saveCookie();
}
/* Save the storage table if not done so already */
$this->_saveStorage();
@@ -1229,13 +1367,11 @@ class classItemMarking
{
/* Check every 5 mins */
$cache = $this->caches['systemvars'];
$update = 0;
/* Fail safe */
if ( ! $cache['itemMarkerClean'] )
{
$cache['itemMarkerClean'] = 0;
$update = 1;
}
if ( time() - 300 > $cache['itemMarkerClean'] )
@@ -1249,6 +1385,10 @@ class classItemMarking
$_time = 1;
}
/* Save Cache BEFORE running clean up to stop race conditions */
$cache['itemMarkerClean'] = time();
$this->cache->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
/* Clean 'em up */
$_c = $this->manualCleanUp( 50, ++$_time, FALSE );
@@ -1256,16 +1396,6 @@ class classItemMarking
{
IPSDebug::addLogMessage( "Manually cleaned up: " . $_c . ' hit by ID ' . $this->memberData['member_id'], 'markerClean' );
}
$update = 1;
}
/* Update */
if ( $update )
{
/* Save Cache */
$cache['itemMarkerClean'] = time();
$this->cache->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
}
}
@@ -1303,46 +1433,6 @@ class classItemMarking
return true;
}
/**
* Check to see if we need to save our markers. Or not.
* And then write them. If we need too. I'm sure you get what
* I mean.
*
* @access protected
* @return boolean If writing was required
*/
protected function _checkThenWriteMarkers()
{
if ( ! $this->settings['topic_marking_enable'] )
{
return FALSE;
}
$_write = FALSE;
if ( $this->settings['topic_marking_save_freq'] == 'page' )
{
$_write = TRUE;
}
else if ( strstr( $this->settings['topic_marking_save_freq'], 'min-' ) )
{
$_min = str_replace( 'min-', '', $this->settings['topic_marking_save_freq'] );
if ( ( time() - $this->_lastSaved ) > ( $_min * 60 ) )
{
$_write = TRUE;
}
}
/* Write, right? */
if ( $_write === TRUE )
{
$this->writeMyMarkersToDB();
}
return $_write;
}
/**
* Build item markers.
* Ok, this function attempts to gather the corret item markers.
@@ -1387,7 +1477,10 @@ class classItemMarking
while( $row = $this->DB->fetch( $itemMarking ) )
{
$items[ $row['item_app'] ][ $row['item_key'] ] = $row;
if ( ! $row['item_is_deleted'] )
{
$items[ $row['item_app'] ][ $row['item_key'] ] = $row;
}
}
}
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Item Marking
* Owner: Matt "Oh Lord, why did I get assigned this?" Mecham
* Last Updated: $Date: 2009-05-08 13:53:41 +0100 (Fri, 08 May 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 4620 $
* @version $Revision: 5713 $
*
* @todo [Future] Perhaps find more ways to reduce the size of items_read
* @todo [Future] Maybe add an IN_DEV tool to warn when markers have been cancelled out / size drastically reduced
@@ -126,7 +128,7 @@ class classItemMarking_debug extends classItemMarking
*
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
*
* @example $read = $itemMarking->isRead( array( 'forumID' => 2, 'itemID' => 99, 'itemLastUpdate' => 1989098989 ) );
* <code>$read = $itemMarking->isRead( array( 'forumID' => 2, 'itemID' => 99, 'itemLastUpdate' => 1989098989 ) );</code>
*
* @access public
* @param array Array of data
@@ -143,8 +145,8 @@ class classItemMarking_debug extends classItemMarking
*
* Forum example (forumID is mapped to :item_app_key_1). itemID is the topic ID
*
* @example $itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) )
* @example $itemMarking->markAsRead( array( 'forumID' => 34 ) )
* <code>$itemMarking->markAsRead( array( 'forumID' => 34, 'itemID' => 99 ) );</code>
* <code>$itemMarking->markAsRead( array( 'forumID' => 34 ) );</code>
*
* @access public
* @param array
@@ -216,7 +218,7 @@ class classItemMarking_debug extends classItemMarking
* Fetch read IDs since last global reset
* Returns IDs read based on incoming data
*
* @example $readIDs = $itemMarking->fetchReadIds( array( 'forumID' => 2 ) );
* <code>$readIDs = $itemMarking->fetchReadIds( array( 'forumID' => 2 ) );</code>
* @access public
* @param array Array of data
* @param strng [App]
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,320 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Generic Mapping Class
* Owner: Matt Mecham
* Last Updated: $Date: 2010-08-03 17:20:16 +0100 (Tue, 03 Aug 2010) $
*
* @example
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 6725 $
*/
/**
* Factory class
*
* @author matt
*
*/
class classes_mapping
{
/**
* App object
* @var object
*/
static private $_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';
$_class = 'classes_mapping_' . $engine;
if ( file_exists( $_file ) )
{
require_once( $_file );
if ( class_exists( $_class ) )
{
self::$_app = new $_class();
}
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 ( file_exists( $this->_getCachePath() . '/' . $file_0 ) && file_exists( $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', 0777 );
@chmod( $this->settings['upload_dir'] . '/maps', 0777 );
}
$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
*/
private function _getCachePath()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_dir'] . '/maps' : $this->settings['upload_dir'];
}
/**
* Returns cache path
* @return string
*/
private function _getCacheUrl()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_url'] . '/maps' : $this->settings['upload_url'];
}
}
@@ -0,0 +1,252 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2010-08-03 17:20:16 +0100 (Tue, 03 Aug 2010) $
*
* @example
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 6725 $
*/
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;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
/**
* Method constructor
*
* @return 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();
define( 'BING_API_KEY', 'AvxfFpDbujzwr7Taq2i0enES55OfCrRviwA17gJAGXkhLwAZKV4eNUdglFMQzlz6' );
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return BING_API_KEY;
}
//$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. */
require_once( IPS_KERNEL_PATH . 'classFileManagement.php' );
$file = new classFileManagement();
/* 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
*/
private function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -0,0 +1,242 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2010-08-03 17:20:16 +0100 (Tue, 03 Aug 2010) $
*
* @example
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 6725 $
*/
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;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
/**
* Method constructor
*
* @return 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. */
require_once( IPS_KERNEL_PATH . 'classFileManagement.php' );
$file = new classFileManagement();
/* 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
*/
private function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Extended Member Functions. Disparate functions that are not required
* on every page view.
* Last Updated: $Date: 2009-09-22 17:31:43 -0400 (Tue, 22 Sep 2009) $
* Last Updated: $Date: 2010-08-05 19:11:01 -0400 (Thu, 05 Aug 2010) $
* </pre>
*
* @author $Author: josh $ (Original: MattMecham)
* @author $Author: bfarber $ (Original: MattMecham)
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
* @version $Revision: 5141 $
* @version $Revision: 6731 $
*
*/
@@ -147,7 +149,7 @@ class memberFunctions
// So, lets do the converteroo
//-----------------------------------------
IPSMember::save( $member['member_id'], array( 'core' => array( 'name' => $name, 'members_l_username' => mb_strtolower( $name ), 'members_seo_name' => $_seoName ) ) );
IPSMember::save( $member['member_id'], array( 'core' => array( 'name' => $name, 'members_l_username' => mb_strtolower( $name ) ) ) );
$this->DB->force_data_type = array( 'member_name' => 'string' );
$this->DB->update( 'moderators', array( 'member_name' => $name ), "member_id=" . $member['member_id'] );
@@ -253,11 +255,11 @@ class memberFunctions
{
if( $field == 'members_display_name' )
{
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_taken'] ) );
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_username_taken' ) );
}
else
{
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_taken'] ) );
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_username_taken' ) );
}
}
}
@@ -272,11 +274,11 @@ class memberFunctions
switch( $e->getMessage() )
{
case 'NO_NAME':
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_no_name'] ) );
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_no_name' ) );
break;
case 'ILLEGAL_CHARS':
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_chars'] ) );
return array( 'members_display_name' => $cleanedName['name'], 'errors' => array( 'dname' => 'reg_error_chars' ) );
break;
}
}
@@ -285,11 +287,11 @@ class memberFunctions
switch( $e->getMessage() )
{
case 'NO_NAME':
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_username_none'] ) );
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_username_none' ) );
break;
case 'ILLEGAL_CHARS':
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => ipsRegistry::getClass( 'class_localization' )->words['reg_error_chars'] ) );
return array( 'username' => $cleanedName['name'], 'errors' => array( 'username' => 'reg_error_chars' ) );
break;
}
}
@@ -332,7 +334,7 @@ class memberFunctions
$error = "";
$banFilters = array();
$_timeCheck = time() - 86400 * $this->memberData['g_dname_date'];
$member = ( isset( $member['member_id'] ) ) ? $member : $this->memberData;
$member = is_array($member) ? $member : array();
$checkField = ( $field == 'members_display_name' ) ? 'members_l_display_name' : 'members_l_username';
//-----------------------------------------
@@ -373,14 +375,17 @@ class memberFunctions
// Grab # changes > 24 hours
//-----------------------------------------
$name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $member['member_id'] . " AND dname_date > $_timeCheck" ) );
$name_count['count'] = intval( $name_count['count'] );
$name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $_timeCheck;
if ( intval( $name_count['count'] ) >= $member['g_dname_changes'] )
if( $member['member_id'] )
{
throw new Exception( "NO_MORE_CHANGES" );
$name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $member['member_id'] . " AND dname_date > $_timeCheck" ) );
$name_count['count'] = intval( $name_count['count'] );
$name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $_timeCheck;
if ( intval( $name_count['count'] ) >= $member['g_dname_changes'] )
{
throw new Exception( "NO_MORE_CHANGES" );
}
}
}
@@ -426,12 +431,30 @@ class memberFunctions
// Check for existing name.
//-----------------------------------------
/* Load the handler if it's not present */
if( ! $this->han_login )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
$this->han_login = new $classToLoad( $this->registry );
$this->han_login->init();
}
if( $member['member_id'] )
{
$this->han_login->nameExistsCheck( $name, $member, $checkField );
if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'NAME_NOT_IN_USE' )
{
return TRUE;
}
}
$this->DB->build( array(
'select' => "{$field}, member_id",
'from' => 'members',
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($name) )."' AND member_id != ".$member['member_id'],
'where' => $checkField . "='" . $this->DB->addSlashes( mb_strtolower($name) ) . "'" . ( $member['member_id'] ? " AND member_id != " . $member['member_id'] : '' ),
'limit' => array( 0,1 ) ) );
$this->DB->execute();
//-----------------------------------------
@@ -446,7 +469,7 @@ class memberFunctions
//-----------------------------------------
// Not allowed to select another's log in name
//-----------------------------------------
if ( $field == 'members_display_name' AND $this->settings['auth_dnames_nologinname'] )
{
$check_name = $this->DB->buildAndFetch( array( 'select' => "{$field}, member_id",
@@ -456,7 +479,7 @@ class memberFunctions
if ( $this->DB->getTotalRows() )
{
if ( $member['member_id'] AND $check_name['member_id'] != $member['member_id'] )
if ( !$member['member_id'] OR $check_name['member_id'] != $member['member_id'] )
{
return TRUE;
}
@@ -464,7 +487,7 @@ class memberFunctions
}
if ( $field == 'name' AND $this->settings['auth_dnames_nologinname'] )
{
{
$check_name = $this->DB->buildAndFetch( array( 'select' => "{$field}, member_id",
'from' => 'members',
'where' => "members_l_display_name='" . $this->DB->addSlashes( mb_strtolower($name) ) . "'",
@@ -472,20 +495,20 @@ class memberFunctions
if ( $this->DB->getTotalRows() )
{
if ( $member['member_id'] AND $check_name['member_id'] != $member['member_id'] )
if ( !$member['member_id'] OR $check_name['member_id'] != $member['member_id'] )
{
return TRUE;
}
}
}
//-----------------------------------------
// Test for unicode name
//-----------------------------------------
$unicodeName = $this->_getUnicodeName( $name );
if ( $unicodeName != $name )
//-----------------------------------------
// Test for unicode name
//-----------------------------------------
$unicodeName = $this->_getUnicodeName( $name );
if ( $unicodeName != $name )
{
//-----------------------------------------
// Check for existing name.
@@ -493,7 +516,7 @@ class memberFunctions
$this->DB->build( array( 'select' => "members_display_name, member_id, email",
'from' => 'members',
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($unicodeName) )."' AND member_id != ".$member['member_id'],
'where' => $checkField . "='". $this->DB->addSlashes( mb_strtolower($unicodeName) ) . "'" . ( $member['member_id'] ? " AND member_id != " . $member['member_id'] : '' ),
'limit' => array( 0,1 ) ) );
$this->DB->execute();
@@ -600,13 +623,14 @@ class memberFunctions
if( ipsRegistry::$settings['username_characters'] )
{
$check_against = preg_quote( ipsRegistry::$settings['username_characters'], "/" );
if( !preg_match( "/^[" . $check_against . "]+$/i", $name ) )
$check_against = str_replace( '\-', '-', $check_against ); // Fix for bug #20998
if( !preg_match( "/^[" . $check_against . "]+$/iu", $name ) )
{
return array( 'name' => $original, 'errors' => array( str_replace( '{chars}', ipsRegistry::$settings['username_characters'], ipsRegistry::$settings['username_errormsg'] ) ) );
}
}
//-----------------------------------------
// Manually check against bad chars
//-----------------------------------------
@@ -794,7 +818,7 @@ class memberFunctions
$upload->out_file_name = 'photo-'.$member_id;
$upload->out_file_dir = $upload_path;
$upload->max_file_size = ($p_max * 1024) * 8; // Allow xtra for compression
$upload->max_file_size = $p_max * 1024;
$upload->upload_form_field = 'upload_photo';
//-----------------------------------------
@@ -876,60 +900,71 @@ class memberFunctions
{
$imageDimensions = getimagesize( $upload_path . '/' . $real_name );
//-----------------------------------------
// Main photo
//-----------------------------------------
if( $imageDimensions[0] > $p_width OR $imageDimensions[1] > $p_height )
{
//-----------------------------------------
// Main photo
//-----------------------------------------
require_once( IPS_KERNEL_PATH."classImage.php" );
require_once( IPS_KERNEL_PATH."classImageGd.php" );
$image = new classImageGd();
$image->init( array(
'image_path' => $upload_path,
'image_file' => $real_name,
) );
'image_path' => $upload_path,
'image_file' => $real_name,
) );
$return = $image->resizeImage( $p_width, $p_height );
$image->writeImage( $upload_path . '/' . 'photo-'.$member_id . '.' . $upload->file_extension );
$t_real_name = $return['thumb_location'] ? $return['thumb_location'] : $real_name;
$im['img_width'] = $return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width'];
$im['img_height'] = $return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height'];
//-----------------------------------------
// MINI photo
//-----------------------------------------
$image->init( array(
'image_path' => $upload_path,
'image_file' => $t_real_name,
) );
$return = $image->resizeImage( $t_width, $t_height );
$image->writeImage( $upload_path . '/' . 'photo-thumb-'.$member_id . '.' . $upload->file_extension );
$t_im['img_width'] = $return['newWidth'];
$t_im['img_height'] = $return['newHeight'];
$t_im['img_location'] = count($return) ? 'photo-thumb-'.$member_id . '.' . $upload->file_extension : $real_name;
}
else
{
$im['img_width'] = $imageDimensions[0];
$im['img_height'] = $imageDimensions[1];
}
//-----------------------------------------
// MINI photo
//-----------------------------------------
if( $imageDimensions[0] > $t_width OR $imageDimensions[1] > $t_height )
{
require_once( IPS_KERNEL_PATH . "classImage.php" );
require_once( IPS_KERNEL_PATH . "classImageGd.php" );
$image = new classImageGd();
//-----------------------------------------
// Mini photo
//-----------------------------------------
$image->init( array(
'image_path' => $upload_path,
'image_file' => $t_real_name,
) );
$return = $image->resizeImage( $t_width, $t_height );
$image->writeImage( $upload_path . '/' . 'photo-thumb-'.$member_id . '.' . $upload->file_extension );
$t_im['img_width'] = $return['newWidth'];
$t_im['img_height'] = $return['newHeight'];
$t_im['img_location'] = count($return) ? 'photo-thumb-'.$member_id . '.' . $upload->file_extension : $real_name;
}
else
{
$_data = IPSLib::scaleImage( array(
'max_height' => $t_height,
'max_width' => $t_width,
'cur_width' => $im['img_width'],
'cur_height' => $im['img_height']
) );
$_data = IPSLib::scaleImage( array( 'max_height' => $t_height,
'max_width' => $t_width,
'cur_width' => $im['img_width'],
'cur_height' => $im['img_height'] ) );
$t_im['img_width'] = $_data['img_width'];
$t_im['img_width'] = $_data['img_width'];
$t_im['img_height'] = $_data['img_height'];
$t_im['img_location'] = $real_name;
}
@@ -1011,6 +1046,222 @@ class memberFunctions
return $return;
}
/**
* Upload background image
* Assumes all security checks have been performed by this point
*
* @access public
* @param integer [Optional] member id instead of current member
* @return array [ error (error message), status (status message [ok/fail] ) ]
*/
public function uploadBackgroundImage( $member_id = 0 )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$return = array( 'error' => '',
'status' => '',
'final_location' => '' );
$member_id = $member_id ? intval($member_id) : intval( $this->memberData['member_id'] );
$p_max = $this->memberData['g_max_bgimg_upload'] ? intval( $this->memberData['g_max_bgimg_upload'] ) : 999999999;
$real_name = '';
$upload_dir = '';
$final_location = '';
if( ! $member_id )
{
return array( 'status' => 'cannot_find_member' );
}
//-----------------------------------------
// Sort out upload dir
//-----------------------------------------
/* Fix for bug 5075 */
$this->settings['upload_dir'] = str_replace( '&#46;', '.', $this->settings['upload_dir'] );
$upload_path = $this->settings['upload_dir'];
# Preserve original path
$_upload_path = $this->settings['upload_dir'];
//-----------------------------------------
// Already a dir?
//-----------------------------------------
if ( ! file_exists( $upload_path . "/bgimages" ) )
{
if ( @mkdir( $upload_path . "/bgimages", 0777 ) )
{
@file_put_contents( $upload_path . '/bgimages/index.html', '' );
@chmod( $upload_path . "/bgimages", 0777 );
# Set path and dir correct
$upload_path .= "/bgimages";
$upload_dir = "bgimages/";
}
else
{
# Set path and dir correct
$upload_dir = "";
}
}
else
{
# Set path and dir correct
$upload_path .= "/bgimages";
$upload_dir = "bgimages/";
}
//-----------------------------------------
// Lets check for an uploaded photo..
//-----------------------------------------
if ( $_FILES['bg_upload']['name'] != "" and ($_FILES['bg_upload']['name'] != "none" ) )
{
//-----------------------------------------
// Are we allowed to upload this photo?
//-----------------------------------------
if ( $p_max < 0 )
{
$return['status'] = 'fail';
$return['error'] = 'no_bgimg_upload_permission';
}
//-----------------------------------------
// Remove any uploaded photos...
//-----------------------------------------
$this->removeUploadedBackgroundImages( $member_id );
$real_name = 'bgimg-'.$member_id;
//-----------------------------------------
// Load the library
//-----------------------------------------
require_once( IPS_KERNEL_PATH.'classUpload.php' );
$upload = new classUpload();
//-----------------------------------------
// Set up the variables
//-----------------------------------------
$upload->out_file_name = 'bgimg-'.$member_id;
$upload->out_file_dir = $upload_path;
$upload->max_file_size = $p_max * 1024;
$upload->upload_form_field = 'bg_upload';
//-----------------------------------------
// Populate allowed extensions
//-----------------------------------------
if ( is_array( $this->cache->getCache('attachtypes') ) and count( $this->cache->getCache('attachtypes') ) )
{
foreach( $this->cache->getCache('attachtypes') as $data )
{
if ( $data['atype_photo'] )
{
if( $data['atype_extension'] == 'swf' AND $this->settings['disable_flash'] )
{
continue;
}
$upload->allowed_file_ext[] = $data['atype_extension'];
}
}
}
//-----------------------------------------
// Upload...
//-----------------------------------------
$upload->process();
//-----------------------------------------
// Error?
//-----------------------------------------
if ( $upload->error_no )
{
switch( $upload->error_no )
{
case 1:
// No upload
$return['status'] = 'fail';
$return['error'] = 'upload_failed';
break;
case 2:
// Invalid file ext
$return['status'] = 'fail';
$return['error'] = 'invalid_file_extension';
break;
case 3:
// Too big...
$return['status'] = 'fail';
$return['error'] = 'upload_to_big';
break;
case 4:
// Cannot move uploaded file
$return['status'] = 'fail';
$return['error'] = 'upload_failed';
break;
case 5:
// Possible XSS attack (image isn't an image)
$return['status'] = 'fail';
$return['error'] = 'upload_failed';
break;
}
return $return;
}
//-----------------------------------------
// Still here?
//-----------------------------------------
$real_name = $upload->parsed_file_name;
$t_real_name = $upload->parsed_file_name;
//-----------------------------------------
// Check the file size (after compression)
//-----------------------------------------
if ( filesize( $upload_path . "/" . $real_name ) > ( $p_max * 1024 ) )
{
@unlink( $upload_path . "/" . $real_name );
// Too big...
$return['status'] = 'fail';
$return['error'] = 'upload_to_big';
return $return;
}
//-----------------------------------------
// Main
//-----------------------------------------
$final_location = $upload_dir . $real_name;
}
else
{
$return['status'] = 'ok';
return $return;
}
//-----------------------------------------
// Return...
//-----------------------------------------
$return['final_location'] = $final_location;
$return['status'] = 'ok';
return $return;
}
/**
* Remove member uploaded photos
@@ -1027,10 +1278,7 @@ class memberFunctions
//-----------------------------------------
$upload_path = $upload_path ? $upload_path : $this->settings['upload_dir'];
# Preserve original path
$_upload_path = $this->settings['upload_dir'];
//-----------------------------------------
// Already a dir?
//-----------------------------------------
@@ -1044,35 +1292,79 @@ class memberFunctions
# Set path and dir correct
$upload_path .= "/profile";
$upload_dir = "profile/";
}
else
{
# Set path and dir correct
$upload_dir = "";
}
}
else
{
# Set path and dir correct
$upload_path .= "/profile";
$upload_dir = "profile/";
}
//-----------------------------------------
// Go...
//-----------------------------------------
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
{
if ( @file_exists( $upload_path."/photo-".$id.".".$ext ) )
{
@unlink( $upload_path."/photo-".$id.".".$ext );
}
if ( @file_exists( $upload_path."/photo-thumb-".$id.".".$ext ) )
//-----------------------------------------
// Only try to delete if we didn't just create dir
//-----------------------------------------
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
{
@unlink( $upload_path."/photo-thumb-".$id.".".$ext );
if ( @file_exists( $upload_path."/photo-".$id.".".$ext ) )
{
@unlink( $upload_path."/photo-".$id.".".$ext );
}
if ( @file_exists( $upload_path."/photo-thumb-".$id.".".$ext ) )
{
@unlink( $upload_path."/photo-thumb-".$id.".".$ext );
}
}
}
}
/**
* Remove member uploaded background images
*
* @access public
* @param integer Member ID
* @param string [Optional] Directory to check
* @return array [ error (error message), status (status message [ok/fail] ) ]
*/
public function removeUploadedBackgroundImages( $id, $upload_path='' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$upload_path = $upload_path ? $upload_path : $this->settings['upload_dir'];
//-----------------------------------------
// Already a dir?
//-----------------------------------------
if ( ! file_exists( $upload_path . "/bgimages" ) )
{
if ( @mkdir( $upload_path . "/bgimages", 0777 ) )
{
@file_put_contents( $upload_path . '/index.html', '' );
@chmod( $upload_path . "/bgimages", 0777 );
# Set path and dir correct
$upload_path .= "/bgimages";
}
}
else
{
# Set path and dir correct
$upload_path .= "/bgimages";
//-----------------------------------------
// Only should bother trying to delete if we didn't
// just create the folder
//-----------------------------------------
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
{
if ( @file_exists( $upload_path."/bgimg-".$id.".".$ext ) )
{
@unlink( $upload_path."/bgimg-".$id.".".$ext );
}
}
}
}
@@ -1207,7 +1499,7 @@ class memberFunctions
$upload->out_file_name = $real_name;
$upload->out_file_dir = $this->settings['upload_dir'];
$upload->max_file_size = ($this->settings['avup_size_max'] * 1024) * 8; // Allow xtra for compression
$upload->max_file_size = $this->settings['avup_size_max'] * 1024;
$upload->upload_form_field = $uploadFieldName;
//-----------------------------------------
@@ -1388,8 +1680,16 @@ class memberFunctions
$directory .= '/';
}
}
$filename = preg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
// BUG #20822
if( function_exists( 'mb_ereg_replace' ) )
{
$filename = mb_ereg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
}
else
{
$filename = preg_replace( "/[^\s\w\._\-\[\]\(\)]/", "", urldecode( $this->request[$avatarGalleryImage] ) );
}
if( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_avatars/' . $directory . $filename ) )
{
@@ -1447,7 +1747,7 @@ class memberFunctions
*/
public function getHostedAvatarsFromCategory( $catName )
{
//$catName = IPSText::alphanumericalClean( $catName ); // Commented out because alphanumericalClean removes spaces
$catName = IPSText::alphanumericalClean( $catName, ' ' ); // Commented out because alphanumericalClean removes spaces
$images = array();
$path = '';
@@ -1540,8 +1840,8 @@ class memberFunctions
*/
private function _sortAvatars( $a, $b )
{
$aa = strtolower($a[1]);
$bb = strtolower($b[1]);
$aa = mb_strtolower($a[1]);
$bb = mb_strtolower($b[1]);
if ( $aa == $bb ) return 0;
@@ -0,0 +1,847 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Notification library
* Last Updated: $Date: 2010-10-08 10:15:14 -0400 (Fri, 08 Oct 2010) $
* </pre>
*
* @author $Author: mark $ (Original: bfarber)
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since Thursday Jan 7, 2010
* @version $Revision: 6956 $
*
* @todo Need to push Downloads, Blog and Gallery into new system
*/
/**
* Notifications class.
* Sends notifications to member(s) based on their configured notification options.
*/
class notifications
{
/**#@+
* Registry objects
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Member data
*
* @access protected
* @var array
*/
protected $_member = array();
/**
* From member data (usually $this->memberData)
*
* @access protected
* @var array
*/
protected $_from = array();
/**
* Notification definitions
*
* @access protected
* @var array
*/
protected $_notificationData = array();
/**
* Notification key
*
* @access protected
* @var string
*/
protected $_notificationKey = '';
/**
* Notification text
*
* @access protected
* @var string
*/
protected $_notificationText = '';
/**
* Notification title
*
* @access protected
* @var string
*/
protected $_notificationTitle = '';
/**
* Notification URL
*
* @access protected
* @var string
*/
protected $_notificationUrl = '';
/**
* CONSTRUCTOR
*
* @param blog_show $class
* @return void
**/
public function __construct( 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();
//-----------------------------------------
// Set default
//-----------------------------------------
$this->_from = $this->memberData;
}
/**
* Get HTML for board index hook
*
* @access public
* @return string
*/
public function getBoardIndexHook()
{
$_notifications = $this->fetchUnreadNotifications(10, 'notify_sent', 'DESC');
//-----------------------------------------
// If none are unread, no HTML
//-----------------------------------------
if( !count($_notifications) )
{
return '';
}
return $this->registry->output->getTemplate('boards')->hookUnreadNotifications( $_notifications );
}
/**
* Set Member
*
* @access public
* @param mixed Member id (int) or member data (array)
* @return void
*/
public function setMember( $member )
{
if( is_int($member) )
{
$member = IPSMember::load( $member );
}
$this->_member = $member;
}
/**
* Set member message should come 'from'
*
* @access public
* @param mixed Member id (int) or member data (array)
* @return void
*/
public function setFrom( $member )
{
if( is_int($member) )
{
$member = IPSMember::load( $member );
}
$this->_from = $member;
}
/**
* Set notification type key
*
* @access public
* @param string Notification type key
* @return void
*/
public function setNotificationKey( $key )
{
$this->_notificationKey = $key;
}
/**
* Set notification URL
*
* @access public
* @param string Notification URL
* @return void
*/
public function setNotificationUrl( $url )
{
$this->_notificationUrl = $url;
}
/**
* Set notification text
*
* @access public
* @param string Text
* @return void
*/
public function setNotificationText( $text )
{
$this->_notificationText = $text;
}
/**
* Set notification title
*
* @access public
* @param string Title
* @return void
*/
public function setNotificationTitle( $title )
{
$this->_notificationTitle = $title;
}
/**
* Get all notification types
*
* @access public
* @return array
*/
public function getNotificationKeys()
{
$data = $this->getNotificationData();
return array_keys( $data );
}
/**
* Get notification config file data
*
* @access public
* @param bool If true, will check show_callback to see if user has permission
* @return array
*/
public function getNotificationData( $checkCallbacks=FALSE )
{
//-----------------------------------------
// Already stored the data?
//-----------------------------------------
if( count($this->_notificationData) )
{
return $this->_notificationData;
}
//-----------------------------------------
// Get for each application
//-----------------------------------------
foreach( ipsRegistry::$applications as $app_dir => $application )
{
if( IPSLib::appIsInstalled( $app_dir) )
{
if( file_exists( IPSLib::getAppDir( $app_dir ) . '/extensions/notifications.php' ) )
{
require_once( IPSLib::getAppDir( $app_dir ) . '/extensions/notifications.php' );
$className = $app_dir . '_notifications';
if ( class_exists( $className ) )
{
$class = new $className();
$class->memberData = ipsRegistry::member()->fetchMemberData();
$_NOTIFY = $class->getConfiguration();
if ( $checkCallbacks )
{
foreach ( $_NOTIFY as $n )
{
if ( $n['show_callback'] and method_exists( $class, $n['key'] ) )
{
if ( $class->$n['key']() )
{
$this->_notificationData[] = $n;
}
}
else
{
$this->_notificationData[] = $n;
}
}
}
else
{
$this->_notificationData = ( is_array( $this->_notificationData ) ) ? $this->_notificationData : array();
$this->_notificationData = array_merge( $this->_notificationData, $_NOTIFY );
}
}
}
}
}
return $this->_notificationData;
}
/**
* Format the notification data as if it were configured
*
* @access public
* @return array
*/
public function formatNotificationData()
{
$_data = $this->getNotificationData();
$_return = array();
foreach( $_data as $data )
{
$_return[ $data['key'] ] = array();
$_return[ $data['key'] ]['selected'] = $data['default'];
$_return[ $data['key'] ]['disabled'] = $data['disabled'];
$_return[ $data['key'] ]['disable_override'] = 0;
}
return $_return;
}
/**
* Get the ACP-set notification configuration
*
* @access public
* @return array
*/
public function getDefaultNotificationConfig()
{
return $this->cache->getCache('notifications') ? $this->cache->getCache('notifications') : $this->formatNotificationData();
}
/**
* Save the ACP-set notification configuration
*
* @access public
* @param array Notification configuration
* @return void
*/
public function saveNotificationConfig( $config )
{
$this->cache->setCache( 'notifications', $config, array( 'array' => 1 ) );
}
/**
* Rebuild notifications cache
*
* @return void
*/
public function rebuildNotificationsCache()
{
$this->saveNotificationConfig( $this->formatNotificationData() );
}
/**
* Get the member's notification configuration
*
* @access public
* @return array
* @link http://community.invisionpower.com/tracker/issue-23529-notification-defaults-dont-apply/
* @link http://community.invisionpower.com/tracker/issue-23663-notification-issues/
*/
public function getMemberNotificationConfig()
{
$_cache = IPSMember::unpackMemberCache( $this->_member['members_cache'] );
if( $_cache['notifications'] )
{
$savedTypes = array_keys( $_cache['notifications'] );
$_default = $this->getDefaultNotificationConfig();
$defaultTypes = array_keys( $_default );
$missingTypes = array_diff( $savedTypes, $defaultTypes );
//-----------------------------------------
// Grab any missing types
//-----------------------------------------
foreach( $missingTypes as $_type )
{
$_cache['notifications'][ $_type ] = $_default[ $_type ]['selected'];
}
//-----------------------------------------
// Make changes if admin has disallowed override
// since we saved our config
//-----------------------------------------
foreach( $_default as $k => $sub )
{
if( $sub['disable_override'] )
{
$_cache['notifications'][ $k ]['selected'] = $sub['selected'];
}
else if( $sub['disabled'] )
{
$_newSelection = array();
if( is_array($_cache['notifications'][ $k ]['selected']) AND count($_cache['notifications'][ $k ]['selected']) )
{
foreach( $_cache['notifications'][ $k ]['selected'] as $_thisType )
{
if( !in_array( $_thisType, $sub['disabled'] ) )
{
$_newSelection[] = $_thisType;
}
}
}
$_cache['notifications'][ $k ]['selected'] = $_newSelection;
}
}
return $_cache['notifications'];
}
else
{
return $this->getDefaultNotificationConfig();
}
}
/**
* Send notification
*
* @access public
* @return bool
* @throws NO_MEMBER_ID, NO_NOTIFY_KEY, BAD_NOTIFY_KEY
*/
public function sendNotification()
{
if( !$this->_member['member_id'] )
{
throw new Exception( 'NO_MEMBER_ID' );
}
if( !$this->_notificationKey )
{
throw new Exception( 'NO_NOTIFY_KEY' );
}
$_config = $this->getMemberNotificationConfig();
if( !$_config[ $this->_notificationKey ] )
{
throw new Exception( 'BAD_NOTIFY_KEY' );
}
//-----------------------------------------
// Send appropriate notifications.
// We can have more than one notification method for each
// notification type.
//-----------------------------------------
if( is_array($_config[ $this->_notificationKey ]) AND count($_config[ $this->_notificationKey ]) )
{
foreach( $_config[ $this->_notificationKey ]['selected'] as $_type )
{
switch( $_type )
{
case 'pm':
$this->_sendPMNotification();
break;
case 'email':
$this->_sendEmailNotification();
break;
case 'inline':
$this->_sendInlineNotification();
break;
case 'mobile':
$this->_sendMobileNotification();
break;
}
}
}
}
/**
* Send a notification via mobile device
*
* @access protected
* @return mixed True, or can output an error
*/
protected function _sendMobileNotification()
{
/* Just save the notification, a task will handle it later */
if( IPSLib::canReceiveMobileNotifications( $this->_member ) && $this->_member['ips_mobile_token'] )
{
$this->DB->insert( 'mobile_notifications', array(
'notify_title' => strip_tags( $this->_notificationTitle ),
'notify_date' => time(),
'member_id' => $this->_member['member_id']
)
);
}
}
/**
* Send a notification via private conversation
*
* @access protected
* @return mixed True, or can output an error
*/
protected function _sendPMNotification()
{
/* Have they disabled their messenger? */
if ( $this->_member['members_disable_pm'] )
{
return;
}
/* No? Okay, carry on */
try
{
$_classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members' );
$_messenger = new $_classToLoad( $this->registry );
$_messenger->sendNewPersonalTopic( intval( $this->_member['member_id'] ),
intval( $this->_from['member_id'] ),
array(),
strip_tags($this->_notificationTitle),
IPSText::getTextClass('editor')->method == 'rte' ? nl2br( $this->_notificationText ) : $this->_notificationText,
array( 'origMsgID' => 0,
'fromMsgID' => 0,
'postKey' => md5(microtime()),
'trackMsg' => 0,
'addToSentFolder' => 0,
'hideCCUser' => 0,
'forcePm' => 1,
'isSystem' => true
)
);
}
catch( Exception $error )
{
$msg = $error->getMessage();
if( $msg != 'CANT_SEND_TO_SELF' )
{
if ( strstr( $msg, 'BBCODE_' ) )
{
$msg = str_replace( 'BBCODE_', '', $msg );
$this->registry->output->showError( $msg, 10149 );
}
else if ( isset($this->lang->words[ 'err_' . $msg ]) )
{
$this->lang->words[ 'err_' . $msg ] = $this->lang->words[ 'err_' . $msg ];
$this->lang->words[ 'err_' . $msg ] = str_replace( '#NAMES#' , implode( ",", $_messenger->exceptionData ) , $this->lang->words[ 'err_' . $msg ] );
$this->lang->words[ 'err_' . $msg ] = str_replace( '#TONAME#' , $this->_member['members_display_name'] , $this->lang->words[ 'err_' . $msg ] );
$this->lang->words[ 'err_' . $msg ] = str_replace( '#FROMNAME#' , $this->_from['members_display_name'] , $this->lang->words[ 'err_' . $msg ] );
$this->registry->output->showError( 'err_' . $msg, 10150 );
}
else
{
$_msgString = $this->lang->words['err_UNKNOWN'] . ' ' . $msg;
$this->registry->output->showError( 'err_UNKNOWN', 10151 );
}
}
}
return true;
}
/**
* Send a notification via email
*
* @access protected
* @return bool
*/
protected function _sendEmailNotification()
{
IPSText::getTextClass( 'email' )->message = $this->_notificationText;
IPSText::getTextClass( 'email' )->subject = strip_tags( $this->_notificationTitle );
IPSText::getTextClass( 'email' )->to = $this->_member['email'];
IPSText::getTextClass( 'email' )->from = $this->settings['email_out'];
//-----------------------------------------
// Send immediately
//-----------------------------------------
//IPSText::getTextClass( 'email' )->sendMail();
//-----------------------------------------
// Send delayed
//-----------------------------------------
$this->DB->insert( 'mail_queue', array( 'mail_to' => IPSText::getTextClass( 'email' )->to, 'mail_from' => IPSText::getTextClass( 'email' )->from, 'mail_date' => time(), 'mail_subject' => IPSText::getTextClass('email')->subject, 'mail_content' => IPSText::getTextClass('email')->message ) );
$cache = $this->cache->getCache('systemvars');
$cache['mail_queue'] += 1;
$this->cache->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
return true;
}
/**
* Send an inline notification
*
* @access protected
* @return bool
*/
protected function _sendInlineNotification()
{
//-----------------------------------------
// First, make sure member doesn't have too many
//-----------------------------------------
$this->_truncateInlineNotifications();
//-----------------------------------------
// Insert new notification
//-----------------------------------------
$_insert = array(
'notify_to_id' => $this->_member['member_id'],
'notify_from_id' => intval($this->_from['member_id']),
'notify_sent' => time(),
'notify_read' => 0,
'notify_title' => $this->_notificationTitle,
'notify_text' => $this->_notificationText,
'notify_type_key' => $this->_notificationKey,
'notify_url' => $this->_notificationUrl,
);
$this->DB->insert( 'inline_notifications', $_insert );
//-----------------------------------------
// Update member record
//-----------------------------------------
$this->DB->update( 'members', 'notification_cnt=notification_cnt+1, msg_show_notification=1', 'member_id=' . $this->_member['member_id'], true, true );
return true;
}
/**
* Clear out old notifications if there's a limit to how many member can have
*
* @access public
* @return void
*/
public function _truncateInlineNotifications()
{
//-----------------------------------------
// Determine member's limit first
//-----------------------------------------
$groups = array( $this->_member['member_group_id'] );
if( $this->_member['mgroup_others'] )
{
$_others = IPSText::cleanPermString( $this->_member['mgroup_others'] );
$groups = ( is_array( $groups ) AND is_array( $_others ) ) ? array_merge( $_others, $groups ) : array();
}
//-----------------------------------------
// 0 is best, otherwise higher is better
//-----------------------------------------
$_limit = 0;
foreach( $groups as $_group )
{
$_thisLimit = $this->caches['group_cache'][ $_group ]['g_max_notifications'];
if( !$_thisLimit )
{
$_limit = 0;
break;
}
else if( $_thisLimit > $_limit )
{
$_limit = $_thisLimit;
}
}
//-----------------------------------------
// We have a limit
//-----------------------------------------
if( $_limit )
{
//-----------------------------------------
// Get current count
//-----------------------------------------
$_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->_member['member_id'] ) );
//-----------------------------------------
// At limit?
// We use >= because this is run immediately before
// we add a new notification, so if we are at limit
// we still need to remove 1
//-----------------------------------------
if( $_count['total'] >= $_limit )
{
$_toDelete = ( $_count['total'] + 1 ) - $_limit;
//-----------------------------------------
// Yes, delete method supports order by and limit
//-----------------------------------------
$this->DB->delete( 'inline_notifications', 'notify_to_id=' . $this->_member['member_id'], 'notify_sent ASC', array( $_toDelete ) );
}
}
return;
}
/**
* Rebuild a member's unread notification count
*
* @access public
* @return void
*/
public function rebuildUnreadCount()
{
$count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'inline_notifications', 'where' => 'notify_to_id=' . $this->_member['member_id'] . ' AND notify_read=0' ) );
$this->DB->update( 'members', array( 'notification_cnt' => $count['total'] ), 'member_id=' . $this->_member['member_id'] );
}
/**
* Fetch new PM notification
*
* @access public
* @param int Number if items to limit
* @param string Sort column
* @param string Sort order
* @param bool Only get unread notifications
* @param bool Run text through preDisplayParse
* @return array Unread notifications
*/
public function fetchUnreadNotifications( $limit=0, $sortKey='notify_sent', $sortOrder='desc', $unread=true, $parseText=false )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$return = array();
$limit = ( $limit ) ? array( 0, intval( $limit ) ) : array( 0, 500 );
//-----------------------------------------
// Fetch unread notifications
//-----------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'inline_notifications',
'where' => 'notify_to_id=' . $this->_member['member_id'] . ( $unread ? ' AND notify_read=0' : '' ),
'order' => $sortKey . ' ' . $sortOrder,
'limit' => $limit ) );
$outer = $this->DB->execute();
while( $row = $this->DB->fetch($outer) )
{
/* As the email template parser makes an attempt to reparse 'safe' HTML, we need to make it safe here */
$row['notify_text'] = IPSText::htmlspecialchars( $row['notify_text'] );
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
if( $parseText )
{
$row['notify_text'] = IPSText::getTextClass('bbcode')->preDisplayParse( nl2br( $row['notify_text'] ) );
}
$row['notify_icon'] = $this->getNotificationIcon( $row['notify_type_key'] );
$return[ $row['notify_sent'] . '.' . $row['notify_id'] ] = $row;
}
/* Got anything? */
if ( ! count( $return ) )
{
return array();
}
/* Reverse sort it (latest first) */
// Removed (bfarber) - this negates the ability to custom sort the returned notifications by passing in 2nd/3rd function
// params, so I'm commenting out for now
//krsort( $return );
/* Return 'em */
return $return;
}
/**
* Get notification icon
*
* @access public
* @param string Notification key
* @return string Notification icon
*/
public function getNotificationIcon( $key )
{
//-----------------------------------------
// Init
//-----------------------------------------
if( !$key )
{
return '';
}
//-----------------------------------------
// Get data
//-----------------------------------------
$this->_notificationData = $this->getNotificationData();
//-----------------------------------------
// Now look for key and return icon
//-----------------------------------------
foreach( $this->_notificationData as $data )
{
if( $data['key'] == $key )
{
return $data['icon'];
}
}
return '';
}
}
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.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,17 +1,19 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Admin Output Library
* Last Updated: $LastChangedDate: 2009-10-23 21:23:07 -0400 (Fri, 23 Oct 2009) $
* Last Updated: $LastChangedDate: 2010-10-11 20:21:22 -0400 (Mon, 11 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @version $Rev: 5283 $
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 6962 $
*
*/
@@ -40,8 +42,6 @@ class adminOutput extends output
* @var string
*/
public $html = '';
public $html_help_title = '';
public $html_help_msg = '';
public $html_main = '';
public $body_extra = '';
public $cm_output = '';
@@ -78,7 +78,7 @@ class adminOutput extends output
* Global messages
*
* @access public
* @access string
* @var string
*/
public $global_message;
public $global_error;
@@ -115,6 +115,14 @@ class adminOutput extends output
* @var string
*/
public $default_tab = '';
/**
* Any extra HTML to stick in the sidebar
*
* @access public
* @var string
*/
public $sidebar_extra = '';
/**
* Constructor
@@ -201,7 +209,7 @@ class adminOutput extends output
}
else
{
$this->showError( "Не удалось загрузить шаблон: $template", 4100, true );
$this->showError( sprintf( $this->lang->words['notemplatefiletoload'], $template ), 4100, true );
}
}
@@ -272,14 +280,13 @@ class adminOutput extends output
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; " . ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'];
}
}
$html = str_replace( '<%CONTENT%>' , $this->html , $this->global_template->global_main_popup_wrapper() );
$html = str_replace( "<%TITLE%>" , $this->html_title , $html );
$html = str_replace( "<%BODYEXTRA%>" , ' '.$this->body_extra , $html );
$html = preg_replace( "#{txt\.(.+?)}#e", "IPSText::\$words['\\1']", $html );
$html = str_replace( '<%CONTENT%>' , $this->html , $this->global_template->global_main_popup_wrapper() );
$html = str_replace( "<%TITLE%>" , $this->html_title , $html );
$html = str_replace( "<%BODYEXTRA%>", ' ' . $this->body_extra , $html );
print $html;
exit();
@@ -392,7 +399,7 @@ class adminOutput extends output
{
$this->_sendOutputSetUp( 'redirect' );
$this->html .= "<iframe src='$url' scrolling='auto' border='0' frameborder='0' width='100%' height='400'></iframe>";
$this->html .= "<iframe src='{$url}' scrolling='auto' border='0' frameborder='0' width='100%' height='400'></iframe>";
$this->html_main .= $this->global_template->global_frame_wrapper();
$this->sendOutput();
@@ -434,9 +441,10 @@ class adminOutput extends output
* @param integer Error code
* @param boolean Log error message
* @param string Extra log data
* @param integer Header code to send (ignored for ACP)
* @return void
*/
public function showError( $message, $code=0, $logError=FALSE, $logExtra='' )
public function showError( $message, $code=0, $logError=FALSE, $logExtra='', $header=500 )
{
$this->_sendOutputSetUp( 'error' );
@@ -537,109 +545,51 @@ class adminOutput extends output
}
//-----------------------------------------
// Sticky tabs
// Context sensitive stuff
//-----------------------------------------
$this->member->setProperty( 'global_sticky_tabs', is_array( $this->memberData['global_sticky_tabs'] ) ? $this->memberData['global_sticky_tabs'] : array() );
//-----------------------------------------
// Keith's help mode (tm)
//-----------------------------------------
if( $this->settings['acp_tutorial_mode'] )
if( !$this->cm_output )
{
/* Is this a non IPS app? */
if ( $this->request['app'] == 'subscriptions' OR ! strstr( IPSLib::getAppDir( $this->request['app'] ), '/other/' ) )
{
// Decided to use request instead of (e.g.) ipsRegistry::$current_application to make it easier for us to map.
// We can change in the future if it's preferred
$check_key = $this->request['app'] . '_' . $this->request['module'] . '_' . $this->request['section'] . '_' . $this->request['do'] . '_';
if ( $this->request['groupHelpKey'] )
{
$check_key .= $this->request['groupHelpKey'];
}
$help .= $this->global_template->help_box( $check_key );
}
else
{
$this->settings['acp_tutorial_mode'] = 0;
}
}
//-----------------------------------------
// Start function proper
//-----------------------------------------
if ( $no_wrapper === FALSE )
{
//-----------------------------------------
// Context sensitive stuff
//-----------------------------------------
if( !$this->cm_output )
{
$_file = IPS_APPLICATION_PATH . 'skin_cp/cp_skin_' . $clean_module . '_context_menu.php';
$_class = 'cp_skin_' . $clean_module . '_context_menu';
if ( file_exists( $_file ) )
{
require $_file;
$context_menu = new $_class( $this->registry );
$cm_function_full = ipsRegistry::$request['do'] ? 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'].'__'.ipsRegistry::$request['do'] : 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'];
$cm_function = 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'];
$cm_module = 'context_menu__' . $clean_module;
if ( method_exists( $_class, $cm_function_full ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_function_full() );
}
else if ( method_exists( $_class, $cm_function ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_function() );
}
else if ( method_exists( $_class, $cm_module ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_module() );
}
else
{
if( ipsRegistry::$request['section'] != 'dashboard' && ipsRegistry::$request['do'] != 'index' )
{
$this->cm_output = $this->global_template->no_context_menu();
}
}
}
else
{
$this->cm_output = $this->global_template->no_context_menu();
}
}
//-----------------------------------------
// Global Context Menu Stuff
//-----------------------------------------
$_file = IPS_ROOT_PATH . "skin_cp/cp_skin_global_context_menu.php";
$_file = IPSLib::getAppDir( IPS_APP_COMPONENT ) . '/skin_cp/cp_skin_' . $clean_module . '_context_menu.php';
$_class = 'cp_skin_' . $clean_module . '_context_menu';
if ( file_exists( $_file ) )
{
require_once $_file;
require $_file;
$global_context = new cp_skin_global_context_menu( $this->registry );
$global_context_output = $global_context->get();
$context_menu = new $_class( $this->registry );
$cm_function_full = ipsRegistry::$request['do'] ? 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'].'__'.ipsRegistry::$request['do'] : 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'];
$cm_function = 'context_menu__' . $clean_module.'__'.ipsRegistry::$request['section'];
$cm_module = 'context_menu__' . $clean_module;
if ( method_exists( $_class, $cm_function_full ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_function_full() );
}
else if ( method_exists( $_class, $cm_function ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_function() );
}
else if ( method_exists( $_class, $cm_module ) )
{
$this->cm_output = $context_menu->__wrap( $context_menu->$cm_module() );
}
else
{
if( ipsRegistry::$request['section'] != 'dashboard' && ipsRegistry::$request['do'] != 'index' )
{
$this->cm_output = $this->global_template->no_context_menu();
}
}
}
else
{
$this->cm_output = $this->global_template->no_context_menu();
}
}
$html = str_replace( '<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper(IPS_DOC_CHAR_SET, $this->_css ) );
}
else
{
$html = str_replace( '<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper_no_furniture(IPS_DOC_CHAR_SET, $this->_css ) );
}
$html = str_replace( '<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper(IPS_DOC_CHAR_SET, $this->_css ) );
//------------------------------------------------
// Message in a bottle?
@@ -657,17 +607,6 @@ class adminOutput extends output
$message .= ( $message ) ? '<br />' . $this->global_template->global_message() : $this->global_template->global_message();
}
//------------------------------------------------
// Help?
//------------------------------------------------
/*if ( isset( $this->html_help_title ) AND isset( $this->html_help_msg ) AND $this->html_help_title != '' )
{
$help = $this->global_template->information_box( $this->html_help_title, $this->html_help_msg ) . "<br >";
}*/
//-----------------------------------------
// Figure out title...
//-----------------------------------------
@@ -680,7 +619,7 @@ class adminOutput extends output
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; " . ipsRegistry::$modules_by_section[ ipsRegistry::$current_application ][ ipsRegistry::$current_module ]['sys_module_title'];
}
}
@@ -708,13 +647,12 @@ class adminOutput extends output
$html = str_replace( "<%TITLE%>" , $this->html_title, $html );
$html = str_replace( "<%SUBMENU%>" , $this->_buildSubMenu() , $html ); # Must be called first
$html = str_replace( "<%MENU%>" , $this->_buildMenu() , $html );
$html = str_replace( "<%SIDEBAR_EXTRA%>" , $this->sidebar_extra , $html );
$html = str_replace( "<%CONTEXT_MENU%>" , $this->cm_output , $html );
$html = str_replace( "<%GLOBAL_CONTEXT_MENU%>", $global_context_output , $html );
$html = str_replace( "<%SECTIONCONTENT%>" , $this->html , $html );
# This has to be called after the menu has been set so that query_string is set correctly
$html = str_replace( "<%MSG%>" , $message , $html );
$html = str_replace( "<%HELP%>" , isset( $help ) ? $help : '', $html );
//-----------------------------------------
// Fix up navigation
@@ -845,12 +783,6 @@ class adminOutput extends output
$html = str_replace( "<body", "<body ".$this->body_extra, $html );
}
//-----------------------------------------
// Lang Replace
//-----------------------------------------
$html = preg_replace( "#{txt\.(.+?)}#e", "\$this->lang->words['\\1']", $html );
//-----------------------------------------
// Emoticons fix
//-----------------------------------------
@@ -895,7 +827,7 @@ class adminOutput extends output
if ( is_array( IPSDebug::$memory_debug ) )
{
$memory .= "<br />\n<div align='center' style='margin-left:auto;margin-right:auto'><div class='tableborder' style='width:75%'>\n<div class='tableheaderalt'>MEMORY USAGE</div><div class='tablerow1' style='padding:6px'>\n";
$memory .= "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
$memory .= "<table width='100%'>\n";
$_c = 0;
foreach( IPSDebug::$memory_debug as $usage )
@@ -928,7 +860,7 @@ class adminOutput extends output
$peak_used = $peak_end - IPS_MEMORY_START;
print $memory;
print "Total Memory Used: " . IPSLib::sizeFormat( $_used ) . " (Peak:".IPSText::sizeFormat( $peak_used ).")";
print "Total Memory Used: " . IPSLib::sizeFormat( $_used ) . " (Peak:" . IPSLib::sizeFormat( $peak_used ).")";
}
$this->_IS_PRINTED = 1;
@@ -979,7 +911,7 @@ class adminOutput extends output
$app = ipsRegistry::$current_application;
$link_array = array();
/* Fetch fke apps */
/* Fetch fake apps */
$fakeApps = $this->registry->output->fetchFakeApps();
$inFakeApp = FALSE;
$fakeApp = '';
@@ -1041,23 +973,12 @@ class adminOutput extends output
continue;
}
if ( ! $data['sys_module_parent'] )
{
$_tab_title = $data['sys_module_title'];
$_tab_key = $data['sys_module_key'];
$_tab_title = $data['sys_module_title'];
$_tab_key = $data['sys_module_key'];
$tabs[ $app ]['items'][ $_tab_key ] = array( 'tab_title' => $_tab_title,
'tab_key' => $_tab_key );
$tabs[ $app ]['data'] = $data;
}
else
{
$_tab_title = $data['sys_module_title'];
$_tab_key = $data['sys_module_key'];
$children[ $app ][ $data['sys_module_parent'] ][ $_tab_key ] = array( 'tab_title' => $_tab_title,
'tab_key' => $_tab_key );
}
$tabs[ $app ]['items'][ $_tab_key ] = array( 'tab_title' => $_tab_title,
'tab_key' => $_tab_key );
$tabs[ $app ]['data'] = $data;
}
}
@@ -1417,6 +1338,7 @@ class adminOutput extends output
}
}
}
//print_r($this->core_nav);
//print_r($this->menu);
if ( isset( $this->menu ) && count( $this->menu ) )
{
@@ -1666,14 +1588,15 @@ class adminOutput extends output
*
* @access public
* @param string Field name
* @param array Options. Multidimensional array in format of array( array( 'value', 'display' ), array( 'value', 'display' ) )
* @param array Options. Multidimensional array in format of array( array( 'value', 'display' ), array( 'value', 'display', 'optgroup_key' ) )
* @param string Default value
* @param string HTML id attribute [defaults to $name]
* @param string Javascript to add to list
* @param string CSS class(es) to add to field
* @param array Optgroups
* @return string Form dropdown list
*/
public function formDropdown( $name, $list=array(), $default_val="", $id="", $js="", $css="" )
public function formDropdown( $name, $list=array(), $default_val="", $id="", $js="", $css="", $optgroups=array() )
{
if ($js != "")
{
@@ -1689,16 +1612,101 @@ class adminOutput extends output
$html = "<select name='{$name}'" . $js . " id='{$id}' class='dropdown{$css}'>\n";
foreach ( $list as $v )
//-----------------------------------------
// Support for optgroups
//-----------------------------------------
if( count($optgroups) )
{
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
$_printed = 0;
foreach ( $list as $v )
{
$selected = ' selected="selected"';
if( $v[2] != '_root_' )
{
continue;
}
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$_printed++;
}
foreach( $optgroups as $_key => $value )
{
$html .= "<optgroup label='{$value}'>\n";
foreach ( $list as $v )
{
if( !$v[2] OR $v[2] != $_key )
{
continue;
}
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
$_printed++;
}
$html .= "</optgroup>\n";
}
if( $_printed < count($list) )
{
$html .= "<optgroup label='{$this->lang->words['optgroup_other']}'>\n";
foreach ( $list as $v )
{
if( $v[2] )
{
continue;
}
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
}
$html .= "</optgroup>\n";
}
}
//-----------------------------------------
// Normal
//-----------------------------------------
else
{
foreach ( $list as $v )
{
$selected = "";
if ( ($default_val !== "") and ($v[0] == $default_val) )
{
$selected = ' selected="selected"';
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
}
$html .= "<option value='" . $v[0] . "'" . $selected . ">" . $v[1] . "</option>\n";
}
$html .= "</select>\n\n";
@@ -1734,13 +1742,13 @@ class adminOutput extends output
}
$html = "<select name='{$name}" . "'" . $js . " id='{$id}' class='dropdown{$css}' multiple='multiple' size='{$size}'>\n";
foreach ($list as $v)
{
$selected = "";
if ( count($default) > 0 )
{
{
if ( in_array( $v[0], $default ) )
{
$selected = ' selected="selected"';
@@ -1841,287 +1849,6 @@ class adminOutput extends output
}
}
/**
* Add a table row
*
* @access public
* @param array Cell data
* @param string CSS clasname
* @param string align value
* @return string HTML
* @deprecated
*/
public function add_td_row( $array, $css="", $align='middle' ) {
if (is_array($array))
{
$html = "<tr>\n";
$count = count($array);
$this->td_colspan = $count;
for ($i = 0; $i < $count ; $i++ )
{
$td_col = $i % 2 ? 'tablerow2' : 'tablerow1';
if ($css != "")
{
$td_col = $css;
}
if (is_array($array[$i]))
{
$text = $array[$i][0];
$colspan = $array[$i][1];
$td_col = $array[$i][2] != "" ? $array[$i][2] : $td_col;
$html .= "<td class='$td_col' colspan='$colspan' valign='$align'>".$text."</td>\n";
}
else
{
if (isset($this->td_header[$i][1]) AND $this->td_header[$i][1] != "")
{
$width = " width='{$this->td_header[$i][1]}' ";
}
else
{
$width = "";
}
$html .= "<td class='$td_col' $width valign='$align'>".$array[$i]."</td>\n";
}
}
$html .= "</tr>\n";
return $html;
}
}
/**
* Add a basic table row
*
* @access public
* @param string Text
* @param string Align value
* @param string HTML id attribute
* @param integer Colspan
* @return string HTML
* @deprecated
*/
public function add_td_basic($text="",$align="left",$id="tablerow1", $colspanint=0) {
$html = "";
$colspan = "";
if ( $colspanint )
{
$this->td_colspan = $colspanint;
}
if ($text != "")
{
if ($this->td_colspan > 0)
{
$colspan = " colspan='".$this->td_colspan."' ";
}
$html .= "<tr><td align='$align' class='$id'".$colspan.">$text</td></tr>\n";
}
return $html;
}
/**
* End a table
*
* @access public
* @return string HTML
* @deprecated
*/
public function end_table() {
$this->td_header = array(); // Reset TD headers
if ($this->has_title == 1)
{
$this->has_title = 0;
return "</table></div><br />\n\n";
}
else
{
return "</table>\n\n";
}
}
/**
* Start a table
*
* @access public
* @param string Title
* @param string Description
* @return string HTML
* @deprecated
*/
public function start_table( $title="", $desc="") {
$html = "";
if ($title != "")
{
$this->has_title = 1;
$html .= "<div class='tableborder'>
<div class='tableheaderalt'>LEGACY -- FIX ME -- $title</div>\n";
if ( $desc != "" )
{
$html .= "<div class='tablesubheader'>$desc</div>\n";
}
}
$html .= "\n<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>";
if (isset($this->td_header[0]))
{
// Auto remove two &nbsp; only headers..
$this->td_header[1][0] = ( isset($this->td_header[1][0]) AND $this->td_header[1][0] ) ? $this->td_header[1][0] : '';
$this->td_header[1][1] = ( isset($this->td_header[1][1]) AND $this->td_header[1][1] ) ? $this->td_header[1][1] : '';
if ( $this->td_header[0][0] == '&nbsp;' && $this->td_header[1][0] == '&nbsp;' && ( ! isset( $this->td_header[2][0] ) ) )
{
$this->td_header[0][0] = '{none}';
$this->td_header[1][0] = '{none}';
}
$tds = "";
foreach ($this->td_header as $td)
{
if ($td[1] != "")
{
$width = " width='{$td[1]}' ";
}
else
{
$width = "";
}
if ($td[0] != '{none}')
{
$tds .= "<td class='tablesubheader'".$width."align='center'>{$td[0]}</td>\n";
}
$this->td_colspan++;
}
if( $tds )
{
$html .= "<tr>\n{$tds}</tr>\n";
}
}
return $html;
}
/**
* Start a form tag
*
* @access public
* @param array Hidden input field names => values
* @param string Form name
* @param string Javascript to add to form tag
* @param string HTML id attribute
* @return string HTML
* @deprecated
*/
public function start_form($hiddens="", $name='theAdminForm', $js="", $id="")
{
if ( ! $id )
{
$id = $name;
}
$form = "LEGACY -- FIX ME --<form action='" . $this->settings['base_url'] . "' method='post' name='$name' $js id='$id'>";
if (is_array($hiddens))
{
foreach ($hiddens as $v)
{
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}' />";
}
}
//-----------------------------------------
// Add in auth key
//-----------------------------------------
$form .= "\n<input type='hidden' name='_admin_auth_key' value='".ipsRegistry::getClass('adminFunctions')->_admin_auth_key."' />";
return $form;
}
/**
* Add hidden input fields to the form
*
* @access public
* @param array Hidden input fields
* @return string HTML
* @deprecated
*/
public function form_hidden($hiddens="")
{
if (is_array($hiddens))
{
foreach ($hiddens as $v)
{
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
}
}
return $form;
}
/**
* End form (expects to be inside a table)
*
* @access public
* @param string Text
* @param string Javascript
* @param string Extra data to put in table cell
* @return string HTML
* @deprecated
*/
public function end_form($text = "", $js = "", $extra = "")
{
$html = "";
$colspan = "";
if ($text != "")
{
if ($this->td_colspan > 0)
{
$colspan = " colspan='".$this->td_colspan."' ";
}
$html .= "<tr><td align='center' class='tablesubheader'".$colspan."><input type='submit' value='$text'".$js." class='realbutton' accesskey='s'>{$extra}</td></tr>\n";
}
$html .= "</form>";
return $html;
}
/**
* Creates a new menu. Array should be in the format: ( link, title, [image], [delete] )
* The image param is optional.
@@ -2151,6 +1878,10 @@ class adminOutput extends output
{
$links[] = "<li style='z-index: 10000;' class='icon {$img}'><a style='z-index: 10000;' href='#' onclick='return acp.confirmDelete(\"{$menu_item[0]}\");'>{$menu_item[1]}</a></li>";
}
else if( ! $menu_item[0] )
{
$links[] = "<li style='z-index: 10000;' class='icon {$img}'><i>{$menu_item[1]}</i></li>";
}
/* Normal Link */
else
{
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2009-08-28 05:22:55 -0400 (Fri, 28 Aug 2009) $
* Last Updated: $Date: 2010-10-28 12:07:41 -0400 (Thu, 28 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5053 $
* @version $Revision: 7063 $
*
*/
@@ -122,6 +124,29 @@ class coreOutput
*/
protected $_outputType = 'normal';
/**
* Store canonical tag
*
* @access protected
* @var string
*/
protected $_canonicalUrl;
/**
* Force download flag
*
* @access protected
* @var boolean
*/
protected $_forceDownload = false;
/**
* Temporary title holder
*
* @var string
*/
public $_current_page_title = '';
/**
* Constructor
* We could use 'extends' and build the registry object up but
@@ -147,6 +172,23 @@ class coreOutput
$this->cache = $output->cache;
$this->caches = $output->caches;
$this->skin = $output->skin;
/* Check for forceDownload */
if ( isset( $_GET['forceDownload'] ) AND $_GET['forceDownload'] AND ( $_GET['_k'] == $this->member->form_hash ) )
{
$this->_forceDownload = true;
}
}
/**
* Set forced download mode
*
* @access protected
* @param boolean
*/
protected function forceDownload( $bool )
{
$this->_forceDownload = ( $bool === true ) ? true : false;
}
/**
@@ -179,16 +221,33 @@ class coreOutput
case 200:
$this->_headerStatus = 'OK';
break;
case 301:
$this->_headerStatus = 'Moved Permanently';
break;
case 403:
$this->_headerStatus = 'Forbidden';
break;
case 404:
$this->_headerStatus = 'Not Found';
break;
case 500:
$this->_headerStatus = 'Internal Server Error';
break;
case 503:
$this->_headerStatus = 'Service Unavailable';
break;
}
}
}
/**
* Add Canonical Tag
* @example: $output->addCanonicalTag( 'showtopic=xx', 'my-test-topic', 'showtopic' );
* <code>$output->addCanonicalTag( 'showtopic=xx', 'my-test-topic', 'showtopic' );</code>
*
* @access public
* @param string URL bit (showtopic=x)
@@ -201,7 +260,16 @@ class coreOutput
/* Build it */
if ( $urlBit AND $seoTemplate )
{
$url = $this->registry->getClass('output')->buildSEOUrl( $urlBit, 'public', $seoTitle, $seoTemplate );
$url = $this->registry->getClass('output')->buildSEOUrl( $urlBit, 'publicNoSession', $seoTitle, $seoTemplate );
/* Strip off /index$ */
if ( substr( $url, -6 ) == '/index' )
{
$url = substr_replace( $url, '', -5 );
}
/* Store it */
$this->_canonicalUrl = $url;
if ( $url )
{
@@ -210,23 +278,45 @@ class coreOutput
}
}
/**
* Fetch Canonical Tag
*
* @access public
* @return string
*/
public function getCanonicalUrl()
{
return ( $this->_canonicalUrl ) ? $this->_canonicalUrl : false;
}
/**
* Add meta tag
* @example: $output->addMetaTag( 'description', 'This is a short description' );
* <code>$output->addMetaTag( 'description', 'This is a short description' );</code>
*
* @access public
* @param string tag name
* @param string tag content
* @param boolean Encode content
* @param int Length to trim to (default 500)
* @return void
* @link http://community.invisionpower.com/tracker/issue-22826-case-sensitivity-in-meta-tags/
*/
public function addMetaTag( $tag, $content, $encode='' )
public function addMetaTag( $tag, $content, $encode='', $trimLen=500 )
{
$encode = ( $encode === FALSE ) ? FALSE : TRUE;
$encode = ( $encode === FALSE ) ? FALSE : TRUE;
$trimLen = ( $trimLen - 3 );
$tag = strtolower($tag); // 'ROBOTS' should overwrite 'robots'
switch( $tag )
{
case 'description':
$content = IPSText::truncate( strip_tags($content), 247 );
/* Clear out 'Quote' if it's present in the bbcode parsed content */
$content = preg_replace( '/\<p class=\'citation\'\>.+?\<\/p\>/ims', '', $content );
# There is no max value, but we trim so we don't bloat the output.
# It's not just search engines that use this, also link sharing services
# pick up the meta description.
$content = IPSText::truncate( strip_tags($content), $trimLen );
break;
case 'keywords':
if ( $encode === TRUE )
@@ -234,7 +324,7 @@ class coreOutput
//Bug #15323 breaks accented characters, etc
//$content = strtolower( preg_replace( "/[^0-9a-zA-Z ]/", "", preg_replace( "/&([^;]+?);/", "", $content ) ) );
$content = str_replace( array( '.', ',', '!', ':', ';', "'", "'", '@', '%', '*', '(', ')' ), '', preg_replace( "/&([^;]+?);/", "", $content ) );
$_vals = preg_split( "/\s+?/", $content, -1, PREG_SPLIT_NO_EMPTY );
$_vals = preg_split( '/\s+?/', $content, -1, PREG_SPLIT_NO_EMPTY );
$_sw = explode( ',', $this->lang->words['_stopwords_'] );
$_fvals = array();
$_limit = 30;
@@ -262,8 +352,29 @@ class coreOutput
}
break;
}
$this->_metaTags[ $tag ] = ( $encode === TRUE ) ? htmlspecialchars( $content ) : $content;
$this->_metaTags[ $tag ] = ( $encode === TRUE ) ? preg_replace( '/&amp;#(\d+?);/', "&#\\1;", htmlspecialchars( $content ) ) : $content;
}
/**
* Retrieve meta tags
* <code>$output->getMetaTags( 'description' );
* $output->getMetaTags();</code>
*
* @access public
* @param string tag name (optional)
* @return mixed Array of meta tags, or meta tag specified if tag name is supplied
*/
public function getMetaTags( $tag='' )
{
if( $tag )
{
return isset( $this->_metaTags[ $tag ] ) ? $this->_metaTags[ $tag ] : '';
}
else
{
return $this->_metaTags;
}
}
/**
@@ -292,8 +403,8 @@ class coreOutput
// Set up defaults
//-----------------------------------------
$this->memberData['msg_count_new'] = intval($this->memberData['msg_count_new']);
$this->memberData['msg_count_total'] = intval($this->memberData['msg_count_total']);
$this->memberData['msg_count_new'] = ( ! empty( $this->memberData['msg_count_new'] ) ) ? intval($this->memberData['msg_count_new']) : 0;
$this->memberData['msg_count_total'] = ( ! empty( $this->memberData['msg_count_total'] ) ) ? intval($this->memberData['msg_count_total']) : 0;
}
/**
@@ -308,47 +419,67 @@ class coreOutput
}
/**
* Fetch applications
* Fetch navigation tabs
*
* @access protected
* @return array
*/
protected function core_fetchApplicationData()
{
foreach( ipsRegistry::$applications as $app_dir => $app_data )
$tabs = array();
/* Check for cache */
if ( ! isset( $this->caches['navigation_tabs'] ) OR ! count( $this->caches['navigation_tabs'] ) )
{
$_appShow = 1;
$_appActive = 0;
$this->registry->cache()->rebuildCache( 'navigation_tabs', 'global' );
if ( IPSLib::appIsInstalled( $app_dir ) !== TRUE )
{
continue;
}
if( $app_data['app_hide_tab'] )
{
continue;
}
if ( $app_dir == 'core' OR $app_dir == 'forums' OR $app_dir == 'members' )
{
$_appShow = 0;
}
if ( IPS_APP_COMPONENT == $app_dir )
{
$_appActive = 1;
}
$applications[ $app_dir ] = array( 'app_dir' => $app_dir,
'app_title' => $app_data['app_public_title'],
'app_show' => $_appShow,
'app_active' => $_appActive,
'app_data' => $app_data );
$this->caches['navigation_tabs'] = $this->registry->cache()->getCache('navigation_tabs');
}
return $applications;
foreach( $this->caches['navigation_tabs'] as $tab )
{
if ( IPSLib::appIsInstalled( $tab['app'] ) !== TRUE )
{
continue;
}
$show = TRUE;
if ( $tab['app'] == 'core' OR $tab['app'] == 'forums' OR $tab['app'] == 'members' )
{
$show = FALSE;
}
$active = FALSE;
if ( ipsRegistry::$current_application == $tab['app'] )
{
if ( $tab['module'] )
{
if ( ipsRegistry::$current_module == $tab['module'] )
{
$active = TRUE;
}
}
else
{
$active = TRUE;
}
}
$link = "app={$tab['app']}";
if ( $tab['module'] )
{
$link = "app={$tab['app']}&amp;module={$tab['module']}";
}
$tabs[] = array( 'app_dir' => $tab['app'],
'app_module' => $tab['module'],
'app_title' => $tab['title'],
'app_show' => $show,
'app_active' => $active,
'app_link' => $link );
}
return $tabs;
}
/**
@@ -383,7 +514,7 @@ class coreOutput
}
else if( $type == 'import' )
{
if( ! $this->_css['import'][$data] )
if( !isset($this->_css['import'][$data]) )
{
$this->_css['import'][$data] = array(
'content' => $data,
@@ -1,15 +1,23 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* (c) IPS, Inc.
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5713 $
*
* Configuration file for output formats
* FORMAT: HTML
*/
$config = array();
/* Identifies publicly as... */
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2009-12-04 03:16:10 -0500 (Fri, 04 Dec 2009) $
* Last Updated: $Date: 2010-10-13 09:23:30 -0400 (Wed, 13 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5518 $
* @version $Revision: 6966 $
*
*/
@@ -27,6 +29,14 @@ class htmlOutput extends coreOutput implements interface_output
*/
protected $output;
/**
* Print only flag
*
* @access protected
* @var bool
*/
protected $_printOnly = false;
/**
* CSS array
*
@@ -46,6 +56,12 @@ class htmlOutput extends coreOutput implements interface_output
{
/* Make object */
parent::__construct( $output );
/* Print only seems only relevant to html method, so... */
if ( isset( $_GET['forcePrint'] ) AND $_GET['forcePrint'] AND ( $_GET['_k'] == $this->member->form_hash ) )
{
$this->_printOnly = true;
}
}
/**
@@ -93,20 +109,29 @@ class htmlOutput extends coreOutput implements interface_output
header("HTTP/1.1 " . $this->_headerCode . ' ' . $this->_headerStatus );
}
header( "Content-type: text/html;charset=" . IPS_DOC_CHAR_SET );
/* Forcing a download? */
if ( $this->_forceDownload )
{
header( "Content-type: unknown/unknown" );
header( "Content-Disposition: attachment; filename=\"" . IPSText::alphanumericalClean( IPSText::transliterate( mb_strtolower( $this->registry->output->getTitle() ) ) ) . ".html\"" );
}
else
{
header( "Content-type: text/html;charset=" . IPS_DOC_CHAR_SET );
}
if ( $this->settings['nocache'] )
{
$expires = ( $this->_headerExpire ) ? gmdate("D, d M Y H:i:s", time() + $this->_headerExpire ) . " GMT" : 0;
$maxAge = $this->_headerExpire;
$nocache = ( ! $this->_headerExpire ) ? ',no-cache' : '';
$expires = ( $this->_headerExpire ) ? gmdate( "D, d M Y H:i:s", time() + $this->_headerExpire ) . " GMT" : gmdate( "D, d M Y H:i:s", time() - 86400 ) . " GMT";
$maxAge = $this->_headerExpire;
$nocache = ( ! $this->_headerExpire ) ? 'no-cache,' : '';
header("Cache-Control: ". $nocache . "must-revalidate, max-age=" . $maxAge);
header("Expires: " . $expires);
header( "Cache-Control: ". $nocache . "must-revalidate, max-age=" . $maxAge );
header( "Expires: " . $expires );
if ( ! $this->_headerExpire )
{
header("Pragma: no-cache");
header( "Pragma: no-cache" );
}
}
}
@@ -235,27 +260,29 @@ class htmlOutput extends coreOutput implements interface_output
if ( $this->_outputType == 'normal' )
{
//-----------------------------------------
// Do we have a PM show?
// Do we have a notification show?
//-----------------------------------------
if ( ( $this->memberData['msg_count_reset'] OR $this->memberData['msg_show_notification'] ) AND ! $this->memberData['members_disable_pm'] )
$notifications = null;
if ( ! empty( $this->memberData['msg_show_notification'] ) AND $this->memberData['_cache']['show_notification_popup'] )
{
if ( ( $this->request['module'] != 'messaging' ) AND ( ! $this->settings['board_offline'] OR $this->memberData['g_access_offline']) )
if ( !$this->settings['board_offline'] OR $this->memberData['g_access_offline'] )
{
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'msg_show_notification' => 0 ) ) );
/* Grab PM Data. We init if we need to recount... */
require_once( IPSLib::getAppDir( "members" ) . '/sources/classes/messaging/messengerFunctions.php' );
$messengerFunctions = new messengerFunctions( $this->registry );
/* Only collect data if we have notifications to show */
if ( $this->memberData['msg_show_notification'] )
if( strpos( ipsRegistry::$settings['query_string_real'], 'area=notificationlog' ) === false )
{
$_data = $messengerFunctions->fetchUnreadNotifications( $this->memberData['member_id'] );
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'msg_show_notification' => 0 ) ) );
/* Grab inline notifications... */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
$notifyLibrary = new $classToLoad( $this->registry );
$notifyLibrary->setMember( $this->memberData );
$_data = $notifyLibrary->fetchUnreadNotifications( 1, 'notify_sent', 'DESC', true, true );
if ( count( $_data ) )
{
$pmData = array_shift( $_data );
$notifications = array_shift( $_data );
}
}
}
@@ -266,6 +293,7 @@ class htmlOutput extends coreOutput implements interface_output
//-----------------------------------------
$http = 'http://';
if ( strpos( $this->settings['board_url'], 'https://' ) === 0 )
{
$http = 'https://';
@@ -291,20 +319,22 @@ class htmlOutput extends coreOutput implements interface_output
//-----------------------------------------
$finalOutput = $this->output->getTemplate('global')->globalTemplate( $output, $documentHeadItems, $this->_css, $jsLoaderItems, $this->_metaTags,
array( 'title' => $title,
'applications' => $this->core_fetchApplicationData(),
array( 'title' => $title,
'applications' => $this->core_fetchApplicationData(),
'page' => $this->_current_page_title ),
array( 'navigation' => $navigation,
'pmData' => $pmData ),
array( 'time' => $this->registry->getClass('class_localization')->getDate( time(), 'SHORT', 1 ),
'lang_chooser' => $this->html_buildLanguageDropDown(),
'skin_chooser' => $this->html_fetchSetsDropDown(),
'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(),
'task' => $task )
array( 'navigation' => $navigation,
'notifications' => $notifications,
'adHeaderCode' => ! empty( $extraData['adHeaderCode'] ) ? $extraData['adHeaderCode'] : '',
'adFooterCode' => ! empty( $extraData['adFooterCode'] ) ? $extraData['adFooterCode'] : '' ),
array( 'time' => $this->registry->getClass('class_localization')->getDate( time(), 'SHORT', 1 ),
'lang_chooser' => $this->html_buildLanguageDropDown(),
'skin_chooser' => $this->html_fetchSetsDropDown(),
'copyright' => $this->html_fetchCopyright() ),
array( 'ex_time' => ( isset($this->request['faster']) AND $this->request['faster'] == 'yes' ) ? $this->_getFasterText() : 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(),
'task' => $task )
);
}
@@ -335,6 +365,15 @@ class htmlOutput extends coreOutput implements interface_output
$finalOutput = $this->output->getTemplate('global_other')->displayPopUpWindow( $documentHeadItems, $this->_css, $jsLoaderItems, $title, $output );
}
//-----------------------------------------
// Set a class on the body for print
//-----------------------------------------
if( $this->_printOnly )
{
$finalOutput = str_replace( "<body", "<body class='printpreview'", $finalOutput );
}
//-----------------------------------------
// Return
//-----------------------------------------
@@ -412,6 +451,19 @@ class htmlOutput extends coreOutput implements interface_output
foreach( $this->registry->getClass('output')->skin['_cssGroupsArray'] as $position => $data )
{
/* Print only */
if ( $this->_printOnly === true )
{
if ( $data['css_group'] != 'ipb_print' )
{
continue;
}
else
{
$this->registry->getClass('output')->skin['_css'][ $data['css_group'] ]['attributes'] = 'media="screen"';
}
}
$this->registry->getClass('output')->skin['_css'][ $data['css_group'] ]['content'] = str_replace( 'http://', 'https://', $this->registry->getClass('output')->skin['_css'][ $data['css_group'] ]['content'] );
}
}
@@ -424,19 +476,32 @@ class htmlOutput extends coreOutput implements interface_output
{
$name = $data['css_group'];
/* Print only */
if ( $this->_printOnly === true )
{
if ( $name != 'ipb_print' )
{
continue;
}
else
{
$this->registry->getClass('output')->skin['_css'][ $name ]['attributes'] = 'media="screen"';
}
}
/* Did we skip it? */
if ( ! isset( $this->registry->getClass('output')->skin['_css'][ $name ] ) )
{
continue;
}
/* Skip IE, print and lo-fi as it's hardcoded in the skin */
/* Skip IE, print and lo-fi as it's hardcoded in the skin */
if ( $name == 'ipb_ie' )
{
continue;
}
if ( $this->registry->getClass('output')->skin['set_css_inline'] AND @file_exists( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/'. $this->registry->getClass('output')->skin['_csscacheid'] .'/'. $name . '.css' ) )
if ( $this->registry->getClass('output')->skin['set_css_inline'] AND @file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/'. $this->registry->getClass('output')->skin['_csscacheid'] .'/'. $name . '.css' ) )
{
$_cssFile = $this->settings['public_dir'] . 'style_css/' . $this->registry->getClass('output')->skin['_csscacheid'] .'/'. $name . '.css';
$this->_css['import'][$_cssFile] = array(
@@ -529,7 +594,7 @@ class htmlOutput extends coreOutput implements interface_output
/* Strip session URL if there wasn't one */
if ( ! IN_ACP AND $this->member->session_type != 'cookie' AND ! $this->request['s'] )
{
$url = preg_replace( "/\?s=([a-zA-Z0-9]{32})(&amp;|&|$)/", '', $url );
$url = preg_replace( '/\?s=([a-zA-Z0-9]{32})(&amp;|&|$)/', '', $url );
}
/* Log it */
@@ -591,9 +656,17 @@ class htmlOutput extends coreOutput implements interface_output
if ( $this->settings['ipb_img_url'] )
{
$text = preg_replace( "#img\s+?src=[\"']public/style_(images|avatars|emoticons)(.+?)[\"'](.+?)?".">#is", "img src=\"".$this->settings['ipb_img_url']."public/style_\\1\\2\"\\3>", $text );
$text = preg_replace( '#img\s+?src=["\']public/style_(images|avatars|emoticons)(.+?)["\'](.+?)?' . '>#is', "img src=\"".$this->settings['ipb_img_url']."public/style_\\1\\2\"\\3>", $text );
}
//-----------------------------------------
// Fix up dates
//-----------------------------------------
if ( strstr( $text, '{timestamp:' ) )
{
$text = preg_replace_callback( '#<!--\{timestamp:(\d+?):([^\}]+?)\}-->#', create_function( '$key', 'return ipsRegistry::getClass(\'class_localization\')->getDate($key[1], \'$key[2]\', 1);' ), $text );
}
return $text;
}
@@ -612,22 +685,36 @@ class htmlOutput extends coreOutput implements interface_output
// CRIMINAL CHARGES
//-----------------------------------------
$version = ( $this->settings['ipb_display_version'] AND $this->settings['ipb_display_version'] != 0 ) ? IPB_VERSION : '';
$version = ( $this->settings['ipb_display_version'] AND $this->settings['ipb_display_version'] != 0 ) ? ' ' . IPB_VERSION : '';
if ($this->settings['ipb_copy_number'] && $this->settings['ips_cp_purchase'])
{
$copyright = "";
/**
* @link http://community.invisionpower.com/tracker/issue-23750-licensed-to-wont-work-if-copyright-removal-purchased/
*/
if ( $this->settings['ipb_reg_show'] and $this->settings['ipb_reg_name'] )
{
$copyright = "<!-- Copyright Information -->
<p id='copyright'>" .
$this->lang->words['licensed_to'] . $this->settings['ipb_reg_name'] .
"</p>\n\t\t<!-- / Copyright -->";
}
else
{
$copyright = "";
}
}
else
{
$copyright = "<!-- Copyright Information -->
<p id='copyright' class='right'>
Форум IP.Board {$version} &copy; ".date("Y")." &nbsp;IPS, In<abbr title='Incorporated'>c</abbr>.
<p id='copyright'>
Система для сообществ IP.Board{$version}
<div style='display: none;'><a href='http://prowebber.ru' title='PROWEBBER.RU - всё для вебмастера!'>PROWEBBER.RU - всё для вебмастера!</a></div>
";
if ( $this->settings['ipb_reg_show'] and $this->settings['ipb_reg_name'] )
{
$copyright .= "<br />Зарегистрирован на: ". $this->settings['ipb_reg_name'];
$copyright .= "<br />" . $this->lang->words['licensed_to'] . $this->settings['ipb_reg_name'];
}
@@ -769,7 +856,7 @@ class htmlOutput extends coreOutput implements interface_output
$cache['task_next_run'] = $cache['task_next_run'] ? $cache['task_next_run'] : 0;
$stats .= "<b>Следующая задача</b> = ".$this->registry->getClass( 'class_localization')->getDate( $cache['task_next_run'], 'LONG' )."\n<br /><b>Time now</b> = ".$this->registry->getClass( 'class_localization')->getDate( time(), 'LONG' );
$stats .= "<b>Следующая задача</b> = ".$this->registry->getClass( 'class_localization')->getDate( $cache['task_next_run'], 'LONG' )."\n<br /><b>Время</b> = ".$this->registry->getClass( 'class_localization')->getDate( time(), 'LONG' );
$stats .= "<br /><b>Сейчас</b> = ".time();
$stats .= "<p>Пользователь: last_visit: " . $this->memberData['last_visit'] . " / " . $this->registry->getClass( 'class_localization')->getDate( $this->memberData['last_visit'], 'LONG' ) . "</p>";
@@ -831,7 +918,7 @@ class htmlOutput extends coreOutput implements interface_output
if ( $stats )
{
$stats = "
<div align='center'>
<div align='center' id='debug_wrapper'>
<div class='row2' style='padding:8px;vertical-align:middle'><a href='#' onclick=\"$('debug').toggle(); return false;\">Скрыть</a></div>
<br />
<div class='tableborder' align='left' id='debug'>
@@ -947,4 +1034,33 @@ class htmlOutput extends coreOutput implements interface_output
return $output;
}
/**
* Get faster text
*
* @access private
* @return string
*/
private function _getFasterText()
{
$texts = array(
'Zooom',
'REALLY fast',
'Quick',
'Lightning',
'Chop chop',
'Expeditive',
'Flash',
'Lickety Split',
'On the double',
'Rapid',
'Velocious',
'Pronto',
'Speedy Gonzales',
'Warp Speed',
'Double espresso',
);
return $texts[ array_rand($texts) ];
}
}
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,13 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Ouput format: XML
* (Matt Mecham)
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* (c) IPS, Inc.
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5713 $
*
* Configuration file for output formats
* FORMAT: XML
*/
$config = array();
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Ouput format: HTML
* (Matt Mecham)
* Last Updated: $Date: 2009-02-16 13:44:12 -0500 (Mon, 16 Feb 2009) $
* Last Updated: $Date: 2010-09-15 17:14:23 -0400 (Wed, 15 Sep 2010) $
* </pre>
*
* @author $Author: josh $
* @author $Author: terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 3998 $
* @version $Revision: 6881 $
*
*/
@@ -74,8 +76,15 @@ class xmlOutput extends coreOutput implements interface_output
print $buffer;
}
header("HTTP/1.0 200 OK");
header("HTTP/1.1 200 OK");
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" );
}
header( "Content-type: text/xml;charset=" . IPS_DOC_CHAR_SET );
if ( $this->settings['nocache'] )
@@ -143,12 +152,10 @@ class xmlOutput extends coreOutput implements interface_output
//-----------------------------------------
$finalOutput = $this->output->getTemplate('global')->globalTemplate( $output, $documentHeadItems, $this->_css, $jsLoaderItems,
array( 'title' => $title,
'applications' => $this->core_fetchApplicationData(),
'page' => $this->_current_page_title ),
array( 'navigation' => $navigation,
'pmData' => $pmData,
'showReportBox' => ($memberCache['report_last_updated'] < $reportsCache['last_updated'] && $memberCache['report_num'] > 0) ? 1 : 0 ),
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(),
@@ -298,7 +305,9 @@ class xmlOutput extends coreOutput implements interface_output
{
$copyright = "<!-- Copyright Information -->
<p id='copyright'>
Форум IP.Board {$version} &copy; ".date("Y")." &nbsp;IPS, In<abbr title='Incorporated'>c</abbr>.
Форум IP.Board
{$version} &copy; ".date("Y")." &nbsp;IPS, <abbr title='Incorporated'>Inc</abbr>.
<div style='display: none;'><a href='http://prowebber.ru' title='PROWEBBER.RU - всё для вебмастера!'>PROWEBBER.RU - всё для вебмастера!</a></div>
";
if ( $this->settings['ipb_reg_show'] and $this->settings['ipb_reg_name'] )
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
+31 -22
View File
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* RSS Import
* Owner: Matt Mecham
* Last Updated: $Date: 2009-02-04 20:03:59 +0000 (Wed, 04 Feb 2009) $
* Last Updated: $Date: 2010-09-29 20:23:38 -0400 (Wed, 29 Sep 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 3887 $
* @version $Revision: 6925 $
*/
/**
@@ -215,6 +217,10 @@ class rss_import
$this->_rssClass->rss_max_show = 100;
}
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_global' ), 'core' );
$this->_settings['LinkBack'] = "<a href=\"{url}\">" . $this->registry->getClass('class_localization')->words['_rssimportsource'] . "</a>";
/* Reset class */
$this->_reset();
}
@@ -341,7 +347,7 @@ class rss_import
/* Error check */
if ( ! $item_data['title'] OR ! $item_data['content'] )
{
$this->errors[] = "No title or content";
$this->errors[] = $this->registry->getClass('class_localization')->words['_rssimportnotoc'];
continue;
}
@@ -377,7 +383,7 @@ class rss_import
continue;
}
$this->DB->build( array( 'select' => '*',
$this->DB->build( array( 'select' => 'rss_guid',
'from' => 'core_rss_imported',
'where' => "rss_foreign_key='" . $this->_key . "' AND rss_guid IN ('".implode( "','", $check_guids )."')" ) );
$i = $this->DB->execute();
@@ -533,13 +539,24 @@ class rss_import
IPSText::getTextClass( 'bbcode' )->parsing_section = 'topics';
/* Force the RTE */
$this->memberData['_canUseRTE'] = true;
$this->registry->member()->setProperty('_canUseRTE', TRUE );
$_POST['ed-0_wysiwyg_used'] = 1;
IPSText::getTextClass( 'editor' )->method = 'rte';
/* Clean up.. */
$content = preg_replace( "#<br />(\r)?\n#is", "<br />", $content );
if ( ! $this->_settings['ParseHtml'] )
{
$_raw = stripslashes($content);
$content = IPSText::getTextClass( 'bbcode' )->preDbParse( IPSText::getTextClass( 'editor' )->processRawPost( $_raw ) );
}
else
{
$content = stripslashes($content);
}
/* Add in Show link... */
if ( $this->_settings['LinkBack'] AND $link )
{
@@ -558,18 +575,10 @@ class rss_import
$content .= $the_link;
}
if ( ! $this->_settings['ParseHtml'] )
{
$_raw = stripslashes($content);
$content = IPSText::getTextClass( 'bbcode' )->preDbParse( IPSText::getTextClass( 'editor' )->processRawPost( $_raw ) );
}
else
{
$content = stripslashes($content);
}
/* few final things */
$content = str_replace( '&amp;raquo;', $this->lang->words['_raquo'], $content );
return $content;
}
@@ -598,8 +607,8 @@ class rss_import
/* Validate Data - HTTP Status Code/Text */
if ( $this->_rssClass->classFileManagement->http_status_code != "200" )
{
$this->errors[0] = "Code: " . $this->_rssClass->classFileManagement->http_status_code;
print_r( $this->errors );
$this->errors[0] = $this->registry->getClass('class_localization')->words['_rssimportcode'] . $this->_rssClass->classFileManagement->http_status_code;
//print_r( $this->errors );
throw new Exception( 'HTTP_STATUS_CODE' );
}
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,700 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Global Search
* Last Updated: $Date: 2010-02-22 17:06:11 +0000 (Mon, 22 Feb 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 5859 $
*/
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();
}
/**
* Slightly nice way of dumping vars and stuff globally
* Yeah, it's an evil global variable, but it's FANCY
*/
class IPSSearchRegistry {
/**
* Registry vars
* @var array
*/
static private $_vars = array();
/**
* Set var
* @param mixed Key
* @param mixed value
*/
static public function set( $k, $v )
{
if ( $k and isset( $v ) )
{
self::$_vars[ $k ] = $v;
}
}
/**
* Get var
* @param mixed
*/
static public function get( $k )
{
if ( isset( self::$_vars[ $k ] ) )
{
return self::$_vars[ $k ];
}
return null;
}
}
/**
* Ties in:
* extensions/search/form.php
* extensions/search/{engine}.php
* extensions/search/format.php
*/
class IPSSearch
{
/**#@+
* Registry Object Shortcuts
*
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Plug in for search
*
* @var object
*/
private $SEARCH;
/**
* Plug in for formatting results
*
* @var object
*/
private $FORMAT;
/**
* App
*
* @var string
*/
private $_app;
/**
* Engine
*
* @var string
*/
private $_engine;
/**
* Result count
*
* @param int
*/
private $_count;
/**
* Result array
*
* @param array
*/
private $_results;
static public $aso;
static public $ask;
static public $ast;
/**
* Setup registry objects
*
* @param object ipsRegistry $registry
* @return void
*/
public function __construct( ipsRegistry $registry, $engine, $app )
{
/* 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 engine */
$this->_engine = strtolower( IPSText::alphanumericalClean( $engine ) );
/* Set app */
$this->_app = IPSText::alphanumericalClean( $app );
/* Quick check */
if ( ! file_exists( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
{
/* Try SQL */
if ( ! $this->_engine != 'sql' )
{
$this->_engine = 'sql';
if ( ! file_exists( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' ) )
{
throw new Exception( "NO_SUCH_ENGINE" );
}
}
else
{
throw new Exception( "NO_SUCH_ENGINE" );
}
}
if ( ! isset( ipsRegistry::$applications[ $this->_app ] ) )
{
throw new Exception( "NO_SUCH_APP" );
}
/* Set in registry */
IPSSearchRegistry::set( 'global.engine', $this->_engine );
IPSSearchRegistry::set( 'global.app' , $this->_app );
/* Load up the relevant engines */
$_className = 'search_' . $this->_engine;
require_once( IPS_ROOT_PATH . 'sources/classes/search/format.php' );
/* Got an app specific file? Lets hope so */
if ( file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php' ) )
{
/* We may not have sphinx specific stuff, so... */
if ( ! file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
{
$this->_engine = 'sql';
if ( ! file_exists( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' ) )
{
throw new Exception( "NO_SUCH_APP_ENGINE" );
}
}
require_once( IPS_ROOT_PATH . 'sources/classes/search/engines/' . $this->_engine . '.php' );
require_once( IPSLib::getAppDir( $this->_app ) . '/extensions/search/engines/' . $this->_engine . '.php' );
/* SEARCH classname */
$_className = 'search_engine_' . $this->_app;
$this->SEARCH = new $_className( $registry );
/* FORMAT file */
require_once( IPSLib::getAppDir( $this->_app ) . '/extensions/search/format.php' );
/* FORMAT classname */
$_className = 'search_format_' . $this->_app;
$this->FORMAT = new $_className( $registry );
/* Grab config */
$CONFIG = array();
require( IPSLib::getAppDir( $this->_app ) . '/extensions/search/config.php' );
if ( is_array( $CONFIG ) && count( $CONFIG ) )
{
foreach( $CONFIG as $k => $v )
{
IPSSearchRegistry::set( 'config.' . $k, $v );
}
}
}
else
{
throw new Exception( "NO_SUCH_APP_ENGINE" );
}
/* Multi content types */
if ( IPSSearchRegistry::get( 'config.contentTypes' ) )
{
$c = IPSSearchRegistry::get( 'config.contentTypes' );
if ( is_array( $c ) AND count( $c ) )
{
/* Set up default content type if supported */
IPSSearchRegistry::set( $this->_app . '.searchInKey' , $c[0] );
/* Filter specific search */
if ( isset( $this->request['search_app_filters'][ $this->_app ]['searchInKey'] ) )
{
IPSSearchRegistry::set( $this->_app . '.searchInKey', $this->request['search_app_filters'][ $this->_app ]['searchInKey'] );
}
}
}
}
/**
* Magic __call methods
* Aka too lazy to create a proper function
*/
public function __call( $funcName, $args )
{
/* Output format stuff.. */
switch ( $funcName )
{
case 'isBoolean':
return $this->SEARCH->isBoolean();
break;
case 'formatSearchTerm':
return $this->SEARCH->formatSearchTerm( $args[0] );
break;
case 'getResultCount':
return $this->_count;
break;
case 'getResultSet':
return $this->_results;
break;
case 'fetchTemplates':
return $this->FORMAT->fetchTemplates();
break;
case 'fetchSortDropDown':
return $this->SEARCH->fetchSortDropDown();
break;
}
}
/**
* Generic: Return sort drop down
*
* @param string App
* @return array
*/
public function fetchSortDropDown( $app='' )
{
$app = ( $app ) ? $app : $this->_app;
/* results page? */
$filter = ( ! IPSSearchRegistry::get('view.search_form') AND IPSSearchRegistry::get( $app . '.searchInKey' ) ) ? IPSSearchRegistry::get( $app . '.searchInKey' ) : '';
if ( file_exists( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
{
require_once( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' );
$_class = 'search_form_' . $app;
if ( class_exists( $_class ) )
{
$_obj = new $_class();
$_dd = $_obj->fetchSortDropDown();
if ( $filter )
{
return $_dd[ $filter ];
}
else
{
return $_dd;
}
}
}
return array( 'date' => $this->lang->words['s_search_type_0'] );
}
/**
* Generic: Return sort in
*
* @param string [App]
* @return array
*/
public function fetchSortIn( $app='' )
{
$app = ( $app ) ? $app : $this->_app;
if ( file_exists( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' ) )
{
require_once( IPSLib::getAppDir( $app ) . '/extensions/search/form.php' );
$_class = 'search_form_' . $app;
if ( class_exists( $_class ) )
{
$_obj = new $_class();
if ( method_exists( $_obj, 'fetchSortIn' ) )
{
return $_obj->fetchSortIn();
}
}
}
return FALSE;
}
/**
* Returns boxes for the search form
*
* @param boolean Grab all apps or just the current one
* @return array
*/
public function getHtml( $allApps = TRUE )
{
/* INIT */
$filtersHtml = '';
/* Loop through apps */
foreach( ipsRegistry::$applications as $app )
{
/* Not all? */
if ( ! $allApps and $app['app_directory'] != $this->_app )
{
continue;
}
if( IPSLib::appisSearchable( $app['app_directory'] ) )
{
/* got custom filter? */
if ( file_exists( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php' ) )
{
require_once( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/search/form.php' );
$_class = 'search_form_' . $app['app_directory'];
if ( class_exists( $_class ) and method_exists( $_class, 'getHtml' ) )
{
$_obj = new $_class();
$filtersHtml[ $app['app_directory'] ] = $_obj->getHtml();
}
else
{
$filtersHtml[ $app['app_directory'] ] = array( 'title' => IPSLib::getAppTitle( $app['app_directory'] ), 'html' => '' );
}
}
else
{
$filtersHtml[ $app['app_directory'] ] = array( 'title' => IPSLib::getAppTitle( $app['app_directory'] ), 'html' => '' );
}
$filtersHtml[ $app['app_directory'] ]['sortDropIn'] = $this->fetchSortIn( $app['app_directory'] );
$filtersHtml[ $app['app_directory'] ]['sortDropDown'] = $this->fetchSortDropDown( $app['app_directory'] );
}
}
return $filtersHtml;
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @return nothin'
*/
public function search()
{
$APP = IPSSearchRegistry::get('in.search_app');
$filterData = $this->request['search_app_filters'][ $APP ];
/* Check for an author filter */
if ( IPSSearchRegistry::get('in.search_author') )
{
/* Query the member id */
$mem = $this->DB->buildAndFetch( array( 'select' => 'member_id',
'from' => 'members',
'where' => "members_display_name='" . $this->DB->addSlashes( IPSSearchRegistry::get('in.search_author') ) . "'" ) );
IPSSearchRegistry::set('opt.searchAuthor', true );
/* Add the condition to our search */
$this->SEARCH->setCondition( 'member_id', '=', $mem['member_id'] ? $mem['member_id'] : -1 );
}
/* Check for application specific filters - just need to do active app here */
$filterData = $this->SEARCH->buildFilterSQL( $filterData );
if( $filterData )
{
if ( isset( $filterData[0] ) )
{
foreach( $filterData as $_data )
{
$this->SEARCH->setCondition( $_data['column'], $_data['operator'], $_data['value'], 'AND' );
}
}
else
{
$this->SEARCH->setCondition( $filterData['column'], $filterData['operator'], $filterData['value'], 'OR' );
}
}
/* Check Date Range */
if( IPSSearchRegistry::get('in.search_date_start') || IPSSearchRegistry::get('in.search_date_end') )
{
/* Start Range Date */
$search_date_start = 0;
if( IPSSearchRegistry::get('in.search_date_start') )
{
$search_date_start = strtotime( IPSSearchRegistry::get('in.search_date_start') );
/* Correct for timezone...hopefully */
$search_date_start += abs( $this->registry->class_localization->getTimeOffset() );
}
/* End Range Date */
$search_date_end = 0;
if( IPSSearchRegistry::get('in.search_date_end') AND IPSSearchRegistry::get('in.search_date_end') != 'now' )
{
$search_date_end = strtotime( IPSSearchRegistry::get('in.search_date_end') );
/* Correct for timezone...hopefully */
$search_date_end += abs( $this->registry->class_localization->getTimeOffset() );
}
/* If the times are exactly equaly, we're going to assume they are trying to search all posts from one day */
if( ( $search_date_start && $search_date_end ) && $search_date_start == $search_date_end )
{
$search_date_end += 86400;
}
$this->SEARCH->setDateRange( $search_date_start, $search_date_end );
}
/* Init session */
$processId = $this->_startSession();
/* Run the search */
$results = $this->SEARCH->search();
/* Set data */
$this->_count = intval( $results['count'] );
$this->_results = $results['resultSet'];
/* Now format results */
if ( count( $this->_results ) )
{
$this->_results = $this->FORMAT->processResults( $this->_results );
/* Now generate HTML */
$this->_results = $this->FORMAT->parseAndFetchHtmlBlocks( $this->_results );
}
/* Kill session */
$this->_endSession( $processId );
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @return nothin'
*/
public function viewNewContent()
{
IPSSearchRegistry::set('display.onlyTitles', true);
/* Hard fix mobile app users to VNC based on unread content */
if ( $this->member->isMobileApp )
{
$this->memberData['bw_vnc_type'] = 1;
}
/* Run the search */
$results = $this->SEARCH->viewNewContent();
/* Set data */
$this->_count = intval( $results['count'] );
$this->_results = $results['resultSet'];
/* Now format results */
if ( count( $this->_results ) )
{
$this->_results = $this->FORMAT->processResults( $this->_results );
/* Now generate HTML */
$this->_results = $this->FORMAT->parseAndFetchHtmlBlocks( $this->_results );
}
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @return nothin'
*/
public function viewUserContent( $member )
{
/* Run the search */
$results = $this->SEARCH->viewUserContent( $member );
/* Set data */
$this->_count = intval( $results['count'] );
$this->_results = $results['resultSet'];
/* Now format results */
if ( count( $this->_results ) )
{
$this->_results = $this->FORMAT->processResults( $this->_results );
/* Now generate HTML */
$this->_results = $this->FORMAT->parseAndFetchHtmlBlocks( $this->_results );
}
}
/**
* Perform the search
*
* @return nothin'
*/
public function viewActiveContent()
{
/* Bit 'o set up */
IPSSearchRegistry::set('opt.searchTitleOnly', IPSSearchRegistry::get('in.view_by_title') );
IPSSearchRegistry::set('display.onlyTitles', true);
IPSSearchRegistry::set('opt.searchTitleOnly', true);
/* Do we have a period? */
switch( IPSSearchRegistry::get('in.period') )
{
case 'today':
default:
$date = 86400; // 24 hours
break;
case 'week':
$date = 604800; // 1 week
break;
case 'weeks':
$date = 1209600; // 2 weeks
break;
case 'month':
$date = 2592000; // 30 days
break;
case 'months':
$date = 15552000; // 6 months
break;
case 'year':
$date = 31536000; // 365 days
break;
}
/* Set date up */
IPSSearchRegistry::set('in.period_in_seconds', $date );
/* Run the search */
$results = $this->SEARCH->viewActiveContent();
/* Set data */
$this->_count = intval( $results['count'] );
$this->_results = $results['resultSet'];
/* Now format results */
if ( count( $this->_results ) )
{
$this->_results = $this->FORMAT->processResults( $this->_results );
/* Now generate HTML */
$this->_results = $this->FORMAT->parseAndFetchHtmlBlocks( $this->_results );
}
}
/**
* Flag a search session
*
* @return int Process ID
*/
private function _startSession()
{
/**
* If we've already run a search and it's not clear, kill it now
*/
if( $this->member->sessionClass()->session_data['search_thread_id'] )
{
$this->DB->return_die = true;
$this->DB->kill( $this->member->sessionClass()->session_data['search_thread_id'] );
$this->DB->return_die = false;
}
/**
* Store the process id
*/
$processId = $this->DB->getThreadId();
if ( $processId )
{
$this->DB->update( 'sessions', array( 'search_thread_id' => $processId, 'search_thread_time' => time() ), "id='" . $this->member->session_id . "'" );
}
return $processId;
}
/**
* End a search session
*
* @return void
*/
private function _endSession( $processId )
{
if ( $processId )
{
$this->DB->update( 'sessions', array( 'search_thread_id' => 0, 'search_thread_time' => 0 ), "id='" . $this->member->session_id . "'" );
}
}
/**
* Custom sort function to avoid filesorts in the system
*
* @param array A
* @param array B
* @return boolean
*/
static function usort( $a, $b )
{
switch ( self::$ast )
{
case 'numeric':
case 'numerical':
if ( self::$aso == 'asc' )
{
return ($a[ self::$ask ] > $b[ self::$ask ]) ? +1 : -1;
}
else
{
return ($a[ self::$ask ] < $b[ self::$ask ]) ? +1 : -1;
}
break;
case 'string':
if ( self::$aso == 'asc' )
{
return strcasecmp($a[ self::$ask ], $b[ self::$ask ]) <= 0 ? -1 : +1;
}
else
{
return strcasecmp($a[ self::$ask ], $b[ self::$ask ]) <= 0 ? +1 : -1;
}
break;
}
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,348 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Global Search
* Last Updated: $Date: 2010-02-19 01:29:54 +0000 (Fri, 19 Feb 2010) $
* </pre>
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 5855 $
*/
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 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( ! file_exists( 'sphinxapi.php' ) )
{
$registry->output->showError( 'sphinx_api_missing', 10182 );
}
/* Load Sphinx */
require( 'sphinxapi.php' );
$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');
$lastActive = IPSLib::fetchHighestNumber( array( intval( $this->memberData['_cache']['gb_mark__' . $app] ), intval( $this->memberData['last_visit'] ) ) );
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
$this->setDateRange( $lastActive, 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('display.onlyTitles' , 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();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewActiveContent()
{
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
/* Set time stamp */
$this->setDateRange( time() - $seconds, 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 void
*/
public function setDateRange( $begin, $end=0 )
{
$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 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 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 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 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 );
}
}
}
@@ -0,0 +1,322 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Global Search
* Last Updated: $Date: 2010-02-22 17:06:11 +0000 (Mon, 22 Feb 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 5859 $
*/
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 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');
$lastActive = IPSLib::fetchHighestNumber( array( intval( $this->memberData['_cache']['gb_mark__' . $app] ), intval( $this->memberData['last_visit'] ) ) );
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
$this->setDateRange( $lastActive, 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('display.onlyTitles' , 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();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @access public
* @return nothin'
*/
public function viewActiveContent()
{
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
/* Set time stamp */
$this->setDateRange( time() - $seconds, 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 = 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 ) ) );
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 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 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 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 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 . ' ' ) . ' ) ';
}
}
@@ -0,0 +1,229 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Global Search
* Last Updated: $Date: 2010-02-22 17:06:11 +0000 (Mon, 22 Feb 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @version $Rev: 5859 $
*/
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 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' );
}
/**
* Fetch templates to use
*
* @access public
* @return array
*/
public function fetchTemplates()
{
return $this->templates;
}
/**
* Formats / grabs extra data for results
* Takes an array of IDS (can be IDs from anything) and returns an array of expanded data.
*
* @access public
* @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 */
foreach( $rows as $id => $r )
{
/* If basic search, strip the content */
IPSText::getTextClass( 'bbcode' )->parse_wordwrap = 0;
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 );
}
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;
}
}
+10 -1
View File
@@ -1 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,469 +0,0 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Global Search
* Last Updated: $Date: 2009-03-04 07:36:56 -0500 (Wed, 04 Mar 2009) $
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Core
* @link http://www.iinvisionpower.com
* @version $Rev: 4135 $
*/
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 searchPluginIndexIndex implements iSearchIndexPlugin
{
/**
* Database object
*
* @access private
* @var object
*/
private $DB;
/**
* Date range restriction start
*
* @access private
* @var integer
*/
private $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access private
* @var integer
*/
private $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access private
* @var array
*/
private $whereConditions = array();
/**
* Apps to exclude
*
* @access public
* @var array
*/
public $exclude_apps = array();
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return void
*/
public function __construct( ipsRegistry $registry )
{
$this->DB = $registry->DB();
$this->member = $registry->member();
$this->memberData =& $registry->member()->fetchMemberData();
}
/**
* Performs search and returns an array of results
*
* @access public
* @param string $search_term
* @param array $limit_clause The erray should be array( begin, end )
* @param string $sort_by Column to sort by
* @param string $group_by Column to group by
* @param bool $content_title_only Only search title records
* @return array
*/
public function getSearchResults( $search_term, $limit_clause, $sort_by, $group_by='', $content_title_only=false )
{
/* Do the search */
$this->DB->build( $this->_buildSearchQueryArray( $search_term, $limit_clause, $sort_by, $group_by, false, $content_title_only ) );
$this->DB->execute();
/* Build result array */
$rows = array();
while( $r = $this->DB->fetch() )
{
$rows[] = $r;
}
return $rows;
}
/**
* Performs live search and returns an array of results
* NOT AVAILABLE IN BASIC SEARCH
*
* @access public
* @param string $search_term
* @return array
*/
public function getLiveSearchResults( $search_term )
{
if( ipsRegistry::$settings['live_search_disable'] )
{
return array();
}
/* Do the search */
$this->DB->build( $this->_buildSearchQueryArray( $search_term, array( 0, 10 ), 'date' ) );
$this->DB->execute();
/* Build result array */
$rows = array();
while( $r = $this->DB->fetch() )
{
$rows[] = $r;
}
return $rows;
}
/**
* Returns the total number of results the search will return
*
* @access public
* @param string $search_term Search term
* @param string $group_by Column to group by
* @param bool $content_title_only Only search title records
* @return integer
*/
public function getSearchCount( $search_term, $group_by='', $content_title_only=false )
{
/* Query the count */
$this->DB->build( $this->_buildSearchQueryArray( $search_term, array(), '', $group_by, true, $content_title_only ) );
$this->DB->execute();
/* Return the count */
if( $group_by )
{
return $this->DB->getTotalRows();
}
else
{
$r = $this->DB->fetch();
return $r['total_results'];
}
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return 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 void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
case 'NOT IN':
$this->whereConditions[$comp][] = "i.{$column} {$operator} ( {$value} )";
break;
default:
$this->whereConditions[$comp][] = "i.{$column} {$operator} {$value}";
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 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 )
{
switch( strtoupper( $r['operator'] ) )
{
case 'IN':
case 'NOT IN':
$_temp[] = "i.{$r['column']} {$r['operator']} ( {$r['value']} )";
break;
default:
$_temp[] = "i.{$r['column']} {$r['operator']} {$r['value']}";
break;
}
}
$this->whereConditions[$outer_comp][] = '( ' . implode( $_temp, ' ' . $inner_comp . ' ' ) . ' ) ';
}
/**
* Reassigns fields in a way the index exepcts
*
* @param array $r
* @return array
**/
public function formatFieldsForIndex( $r )
{
}
/**
* This function grabs the actual results for display
*
* @param array $ids
* @return query result
**/
public function getResultsForSphinx( $ids )
{
}
/**
* Builds an array that can be used in build
*
* @access public
* @param string $search_term
* @param array $limit_clause The erray should be array( begin, end )
* @param string $sort_by Either relevance or date
* @param string [$group_by] Field to group on
* @param bool [$count_only] Set to true for a count(*) query
* @param bool [$content_title_only] Set to true to only search titles
* @return array
*/
private function _buildSearchQueryArray( $search_term, $limit_clause, $sort_by, $group_by='', $count_only=false, $content_title_only=false )
{
/* Do we only need to count results? */
if( $count_only )
{
if( $group_by )
{
$group_by = 'i.' . $group_by;
}
$search_query_array = array(
'select' => 'COUNT(*) as total_results',
'from' => array( 'search_index' => 'i' ),
'where' => $this->_buildWhereStatement( $search_term, $content_title_only ),
'group' => $group_by,
'add_join' => array(
array(
'from' => array( 'permission_index' => 'p' ),
'where' => 'p.perm_type_id=i.type_id AND p.perm_type=i.type',
'type' => 'left',
),
array(
'from' => array( 'profile_friends' => 'friend' ),
'where' => 'friend.friends_member_id=i.member_id AND friend.friends_friend_id=' . $this->memberData['member_id'],
'type' => 'left',
),
)
);
}
else
{
/* Sort By */
if( isset( $sort_by ) && in_array( $sort_by, array( 'date', 'relevance', 'ascdate' ) ) )
{
$_ord = strstr( $sort_by, 'asc' ) ? 'ASC' : 'DESC';
$order = $sort_by == 'date' ? 'i.updated ' . $_ord : 'ranking' . $_ord;
}
else
{
$order = 'ranking DESC';
}
/* If there is no search term, we need to force search by updated */
if( ! $search_term )
{
$order = 'i.updated DESC';
}
if( $group_by )
{
$group_by = 'i.' . $group_by;
}
if( $content_title_only )
{
$ranking_select = $search_term ? ", MATCH( i.content_title ) AGAINST( '{$search_term}' IN BOOLEAN MODE ) as ranking" : '';
}
else
{
$ranking_select = $search_term ? ", MATCH( i.content, i.content_title ) AGAINST( '{$search_term}' IN BOOLEAN MODE ) as ranking" : '';
}
/* Build the search query array */
$search_query_array = array(
'select' => "i.*{$ranking_select}",
'from' => array( 'search_index' => 'i' ),
'where' => $this->_buildWhereStatement( $search_term, $content_title_only ),
'limit' => $limit_clause,
'group' => $group_by,
'order' => $order,
'add_join' => array(
array(
'select' => 'p.perm_view',
'from' => array( 'permission_index' => 'p' ),
'where' => 'p.perm_type_id=i.type_id AND p.perm_type=i.type',
'type' => 'left',
),
array(
'select' => 'm.members_display_name, m.member_group_id, m.mgroup_others',
'from' => array( 'members' => 'm' ),
'where' => 'i.member_id=m.member_id',
'type' => 'left',
),
array(
'from' => array( 'profile_friends' => 'friend' ),
'where' => 'friend.friends_member_id=i.member_id AND friend.friends_friend_id=' . $this->memberData['member_id'],
'type' => 'left',
),
)
);
}
/* Loop through all the search plugins and let them modify the search query */
foreach( ipsRegistry::$applications as $app )
{
if( IPSSearchIndex::appisSearchable( $app['app_directory'] ) )
{
if( ! isset( $this->display_plugins[ $app['app_directory'] ] ) || ! $this->display_plugins[ $app['app_directory'] ] )
{
require_once( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/searchDisplay.php' );
$_class = $app['app_directory'] . 'SearchDisplay';
$this->display_plugins[ $app['app_directory'] ] = new $_class();
}
if( method_exists( $this->display_plugins[ $app['app_directory'] ] , 'modifySearchQuery' ) )
{
/* Get the modified query */
$new_query = $this->display_plugins[ $app['app_directory'] ]->modifySearchQuery( $search_query_array, $count_only );
/* Simple check to prevent accidentaly breaking the query, clearly not fool proof :) */
$search_query_array = is_array( $new_query ) && count( $new_query ) ? $new_query : $search_query_array;
}
}
}
return $search_query_array;
}
/**
* Builds the where portion of a search string
*
* @access private
* @param string $search_term The string to use in the search
* @param bool $content_title_only Search only title records
* @return string
**/
private function _buildWhereStatement( $search_term, $content_title_only=false )
{
/* INI */
$where_clause = array();
if( $search_term )
{
/* Main Search Statement */
if( $content_title_only )
{
$where_clause[] = "MATCH( i.content_title ) AGAINST( '$search_term' IN BOOLEAN MODE )";
}
else
{
$where_clause[] = "MATCH( i.content, i.content_title ) AGAINST( '$search_term' IN BOOLEAN MODE )";
}
}
/* Exclude Apps */
if( count( $this->exclude_apps ) )
{
$where_clause[] = 'i.app NOT IN ( ' . implode( ',', $this->exclude_apps ) . ' )';
}
/* Exclude some items */
if( !$this->memberData['g_is_supmod'] )
{
/* Owner only */
$where_clause[] = '(p.owner_only=0 OR i.member_id=' . $this->memberData['member_id'] . ')';
/* Friend only */
$where_clause[] = '(p.friend_only=0 OR friend.friends_id ' . $this->DB->buildIsNull( false ) . ')';
/* Authorized users only */
$where_clause[] = '(p.authorized_users ' . $this->DB->buildIsNull() . ' OR i.member_id=' . $this->memberData['member_id'] . " OR p.authorized_users LIKE '%," . $this->memberData['member_id'] . ",%')";
}
/* Date Restrict */
if( $this->search_begin_timestamp && $this->search_end_timestamp )
{
$where_clause[] = "i.updated BETWEEN {$this->search_begin_timestamp} AND {$this->search_end_timestamp}";
}
else
{
if( $this->search_begin_timestamp )
{
$where_clause[] = "i.updated > {$this->search_begin_timestamp}";
}
if( $this->search_end_timestamp )
{
$where_clause[] = "i.updated < {$this->search_end_timestamp}";
}
}
/* Add in AND where conditions */
if( isset( $this->whereConditions['AND'] ) && count( $this->whereConditions['AND'] ) )
{
$where_clause = array_merge( $where_clause, $this->whereConditions['AND'] );
}
/* ADD in OR where conditions */
if( isset( $this->whereConditions['OR'] ) && count( $this->whereConditions['OR'] ) )
{
$where_clause[] = '( ' . implode( ' OR ', $this->whereConditions['OR'] ) . ' )';
}
/* Permissions */
$where_clause[] = $this->DB->buildRegexp( "p.perm_view", $this->member->perm_id_array );
/* Build and return the string */
return implode( " AND ", $where_clause );
}
}
File diff suppressed because it is too large. Load diff
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Admin session handler
* Last Updated: $Date: 2009-08-24 20:56:22 -0400 (Mon, 24 Aug 2009) $
* Last Updated: $Date: 2010-09-16 10:57:26 -0400 (Thu, 16 Sep 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since Who knows...
* @version $Revision: 5041 $
* @version $Revision: 6883 $
*
*/
@@ -222,6 +224,9 @@ class adminSessions extends ips_MemberRegistry
{
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' );
}
@@ -237,6 +242,9 @@ class adminSessions extends ips_MemberRegistry
if ( $first_ip != $second_ip )
{
self::$data_store = array();
self::setMember( 0 );
$this->_validated = FALSE;
return $this->_response( 0, 'session_mismatchip' );
}
@@ -347,7 +355,7 @@ class adminSessions extends ips_MemberRegistry
*/
public function getMessage()
{
return $this->registry->class_localization->words[ $this->_message ];
return ( isset($this->registry->class_localization->words[ $this->_message ]) AND $this->registry->class_localization->words[ $this->_message ] ) ? $this->registry->class_localization->words[ $this->_message ] : $this->_message;
}
/**
@@ -0,0 +1,199 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Session API
* Created by Matt Mecham
* Last Updated: $Date: 2010-10-05 02:50:24 +0100 (Tue, 05 Oct 2010) $
* </pre>
*
* @author Matt Meckum
* @copyright (c) 2001 - 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 6942 $
*
*/
class session_api
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @param object Registry object
* @access public
* @return 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
* @param array 'fetch' (all, members, guests)
* @return array ('stats' => array( 'members', 'guests', 'anon' ), 'rows' => array( ... ) )
*/
public function getUsersIn( $app, $options=array() )
{
$return = array( 'stats' => array( 'total' => 0,
'members' => 0,
'guests' => 0,
'bots' => 0,
'anon' => 0 ),
'rows' => array( 'members' => array(),
'bots' => array(),
'guests' => array(),
'anon' => array() ) );
$limit = time() - ( $this->settings['au_cutoff'] * 60 );
$rows = array();
$NOWJIM = time();
$cached = array();
$where = array( "s.current_appcomponent='" . $app . "'", "s.running_time > " . $limit );
if ( $this->memberData['member_id'] )
{
$rows[ $NOWJIM . '.' . $this->memberData['member_id'] ] = array_merge( array( 'id' => $this->member->session_id,
'login_type' => substr($this->memberData['login_anonymous'],0, 1),
'running_time' => $NOWJIM,
'member_id' => $this->memberData['member_id'],
'member_name' => $this->memberData['members_display_name'],
'member_group' => $this->memberData['member_group_id'],
'seo_name' => $this->memberData['members_seo_name'] ), $this->memberData );
}
/* Dee bee */
$this->DB->build( array( 'select' => 's.*',
'from' => array( 'sessions' => 's' ),
'where' => implode( ' AND ', $where ),
'add_join' => array( array( 'select' => 'm.*',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=s.member_id',
'type' => 'left' ) ) ) );
$this->DB->execute();
while( $session = $this->DB->fetch() )
{
if ( ! empty( $session['member_id'] ) AND $session['member_id'] == $this->memberData['member_id'] )
{
continue;
}
$rows[ $session['running_time'] . '.' . $session['id'] ] = $session;
}
krsort( $rows );
/* Process them */
$filename = IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php';
if ( file_exists( $filename ) )
{
$classToLoad = IPSLib::loadLibrary( $filename, 'publicSessions__' . $app, $app );
$loader = new $classToLoad();
if ( method_exists( $loader, 'parseOnlineEntries' ) )
{
$rows = $loader->parseOnlineEntries( $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( 0 );
$result['parsedMemberName'] = $result['member_name'];
$return['rows']['bots'][] = $result;
$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;
$return['stats']['guests']++;
}
/* Member */
else
{
if ( empty( $cached[ $result['member_id'] ] ) )
{
$cached[ $result['member_id'] ] = 1;
$result = IPSMember::buildProfilePhoto( $result );
$result['parsedMemberName'] = IPSLib::makeNameFormatted( $result['member_name'], $result['member_group'] );
if ( $result['login_type'] )
{
if ( $this->memberData['g_access_cp'] and ( $this->settings['disable_admin_anon'] != 1 ) )
{
$result['parsedMemberName'] = IPSLib::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$return['rows']['anon'][] = $result;
}
$return['stats']['anon']++;
}
else
{
$result['parsedMemberName'] = IPSLib::makeProfileLink( $result['parsedMemberName'], $result['member_id'], $result['seo_name'] );
$return['rows']['members'][] = $result;
$return['stats']['members']++;
}
}
}
}
$return['stats']['total'] = intval( $return['stats']['bots'] ) + intval( $return['stats']['guests'] ) + intval( $return['stats']['anon'] ) + intval( $return['stats']['members'] );
return $return;
}
}
@@ -1,73 +1,75 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* This class overrides parent publicSessions to prevent construct being called
* It doesn't do anything else...
* Last Updated: $Date: 2009-02-16 11:03:34 -0500 (Mon, 16 Feb 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage IP.Converge
* @link http://www.iinvisionpower.com
* @since 22nd May 2008 11:15 AM
* @version $Revision: 3992 $
*
*/
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 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.1.4
* This class overrides parent publicSessions to prevent construct being called
* It doesn't do anything else...
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage IP.Converge
* @link http://www.invisionpower.com
* @since 22nd May 2008 11:15 AM
* @version $Revision: 5713 $
*
*/
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 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 +1,10 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Public session handler
* Last Updated: $Date: 2009-10-14 07:03:55 -0400 (Wed, 14 Oct 2009) $
* Last Updated: $Date: 2010-10-06 06:09:32 -0400 (Wed, 06 Oct 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 26th January 2004
* @version $Revision: 5229 $
* @version $Revision: 6946 $
*
*/
@@ -551,7 +553,14 @@ class publicSessions extends ips_MemberRegistry
}
else
{
@header('HTTP/1.1 403 Forbidden');
if ( isset( $_SERVER['SERVER_PROTOCOL'] ) AND strstr( $_SERVER['SERVER_PROTOCOL'], '/1.0' ) )
{
@header('HTTP/1.0 403 Forbidden');
}
else
{
@header('HTTP/1.1 403 Forbidden');
}
}
@header("Cache-Control: no-cache, must-revalidate, max-age=0");
@@ -567,7 +576,7 @@ class publicSessions extends ips_MemberRegistry
// Still no member id and not a bot?
//-----------------------------------------
if ( ! self::$data_store['member_id'] AND ! $this->_member->is_not_human )
if ( empty( self::$data_store['member_id'] ) AND ! $this->_member->is_not_human )
{
self::setMember(0);
@@ -579,8 +588,8 @@ class publicSessions extends ips_MemberRegistry
// Set a session ID cookie
//-----------------------------------------
$this->_member->session_type = $this->session_type;
$this->_member->session_id = $this->session_id;
$this->_member->session_type = $this->session_type;
$this->_member->session_id = $this->session_id;
IPSCookie::set("session_id", $this->session_id, -1);
}
@@ -596,7 +605,7 @@ class publicSessions extends ips_MemberRegistry
*/
public function addQueryKey( $key, $value, $sessionID='' )
{
$sessionID = ( $sessionID ) ? IPSText::md5Clean( $sessionID ) : $this->session_id;
$sessionID = ( $sessionID ) ? substr( IPSText::alphanumericalClean( $sessionID, '_=' ), 0, 32 ) : $this->session_id;
if ( $key )
{
@@ -672,7 +681,6 @@ class publicSessions extends ips_MemberRegistry
'member_group' => self::$data_store['member_group_id'],
'login_type' => intval(substr(self::$data_store['login_anonymous'],0, 1)),
'running_time' => IPS_UNIX_TIME_NOW,
'location' => isset( $vars['location'] ) ? $vars['location'] : '',
'in_error' => 0,
'current_appcomponent' => $this->current_appcomponent,
'current_module' => $this->current_module,
@@ -697,7 +705,7 @@ class publicSessions extends ips_MemberRegistry
/* Reset some data */
$this->session_type = 'cookie';
$this->session_id = "";
//$this->session_id = "";
}
/* Set type */
@@ -777,7 +785,6 @@ class publicSessions extends ips_MemberRegistry
'member_group' => $memberGroup,
'login_type' => $loginType,
'running_time' => IPS_UNIX_TIME_NOW,
'location' => $vars['location'],
'in_error' => 0,
'current_appcomponent' => $this->current_appcomponent,
'current_module' => $this->current_module,
@@ -802,7 +809,7 @@ class publicSessions extends ips_MemberRegistry
/* Reset some data */
$this->session_type = 'cookie';
$this->session_id = "";
//$this->session_id = "";
}
/* Set type */
@@ -868,7 +875,6 @@ class publicSessions extends ips_MemberRegistry
'running_time' => IPS_UNIX_TIME_NOW,
'ip_address' => $this->_member->ip_address,
'browser' => $this->_userAgent,
'location' => isset( $vars['location'] ) ? $vars['location'] : '',
'in_error' => 0,
'current_appcomponent' => $this->current_appcomponent,
'current_module' => $this->current_module,
@@ -943,7 +949,7 @@ class publicSessions extends ips_MemberRegistry
/* Reset some data */
$this->session_type = 'cookie';
$this->session_id = "";
//$this->session_id = "";
}
/* Set type */
@@ -1044,7 +1050,6 @@ class publicSessions extends ips_MemberRegistry
'running_time' => IPS_UNIX_TIME_NOW,
'ip_address' => $this->_member->ip_address,
'browser' => substr( $this->_member->user_agent, 0, 200 ),
'location' => $vars['location'],
'in_error' => 0,
'current_appcomponent' => $this->current_appcomponent,
'current_module' => $this->current_module,
@@ -1083,7 +1088,7 @@ class publicSessions extends ips_MemberRegistry
/* Reset some data */
$this->session_type = 'cookie';
$this->session_id = "";
//$this->session_id = "";
}
/* Set type */
@@ -1097,20 +1102,24 @@ class publicSessions extends ips_MemberRegistry
*
* @access public
* @param array Array of incoming data (member_id, member_name, member_group, login_type)
* @param array Optional array of member data (prevents having to reload it)
* @return string Current session ID
*/
public function convertGuestToMember( $data )
public function convertGuestToMember( $data, $member=array() )
{
/* Delete old sessions */
$this->_destroySessions( "ip_address='" . $this->_member->ip_address . "' AND id != '{$this->session_id}'" );
/* Fetch member */
$member = IPSMember::load( $data['member_id'], 'core' );
if( !$member['member_id'] )
{
$member = IPSMember::load( $data['member_id'], 'core' );
}
/* Update this session directly */
$this->DB->update( 'sessions', array(
'member_name' => $data['member_name'],
'seo_name' => IPSText::makeSeoTitle( $data['member_name'] ),
'seo_name' => $member['members_seo_name'],
'member_id' => $data['member_id'],
'running_time' => time(),
'member_group' => $data['member_group'],
@@ -1126,10 +1135,6 @@ class publicSessions extends ips_MemberRegistry
{
$update['last_visit'] = $member['last_activity'];
}
else
{
$update['last_visit'] = time();
}
/* Make sure last activity and last visit are up to date */
IPSMember::save( $data['member_id'], array( 'core' => $update ) );
@@ -1157,12 +1162,13 @@ class publicSessions extends ips_MemberRegistry
$this->_destroySessions( "ip_address='" . $this->_member->ip_address . "' AND id != '{$this->session_id}'" );
/* Update this session directly */
$this->DB->update( 'sessions', array(
'member_name' => '',
'seo_name' => '',
'member_id' => 0,
'running_time' => time(),
'member_group' => $this->settings['guest_group'] ) , "id='" . $this->session_id . "'", TRUE );
$data = array( 'member_name' => '',
'seo_name' => '',
'member_id' => 0,
'running_time' => time(),
'member_group' => $this->settings['guest_group'] );
$this->DB->update( 'sessions', $data, "id='" . $this->session_id . "'", TRUE );
/* Remove from update and delete array */
unset( $this->_sessionsToSave[ $this->session_id ] );
@@ -1233,7 +1239,7 @@ class publicSessions extends ips_MemberRegistry
//-----------------------------------------
$result = array();
$session_id = IPSText::md5Clean( $session_id );
$session_id = substr( IPSText::alphanumericalClean( $session_id, '_=' ), 0, 32 );
if ( $session_id )
{
@@ -1321,7 +1327,6 @@ class publicSessions extends ips_MemberRegistry
$this->session_id = $this->session_data['id'];
$this->session_user_id = $this->session_data['member_id'];
$this->last_click = $this->session_data['running_time'];
$this->location = $this->session_data['location'];
IPSDebug::addLogMessage( "Authorization attempt successful: Session ID={$session_id}, member ID={$this->session_data['member_id']} ", 'sessions-' . $this->session_data['member_id'] );
@@ -1466,7 +1471,7 @@ class publicSessions extends ips_MemberRegistry
//-----------------------------------------
$memberID = intval( $memberID );
$sessionID = IPSText::md5Clean( $sessionID );
$sessionID = substr( IPSText::alphanumericalClean( $sessionID, '_=' ), 0, 32 );
$_data = array();
$_ignore = array( 'id',
'member_id',
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Sample SSO Class
* Last Updated: $Date: 2009-08-18 21:46:25 +0100 (Tue, 18 Aug 2009) $
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 22nd Septmeber 2009
* @version $Revision: 5027 $
* @version $Revision: 5713 $
*
*/
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,572 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Share links library.
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
class share_links
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Plug in object
*
* @access private
* @var object
*/
protected $_plugin;
protected $_pluginKey = '';
/**
* Construct.
* @access public
* @param object Registry
* @param string Plug in key
* @return void
*/
public function __construct( $registry, $plugin )
{
/* 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();
/* Store */
$this->_pluginKey = $plugin;
try
{
$this->_initPlugin( $plugin );
}
catch ( Exception $e )
{
return $e->getMessage();
}
}
/**
* Share the link.
*
* @access public
* @param string Document title
* @param string Document URL
*/
public function share( $title, $url )
{
/* Disabled? */
if ( ! $this->settings['sl_enable'] )
{
return false;
}
/* Ensure title is correctly de-html-ized */
$title = IPSText::UNhtmlspecialchars( $title );
if ( is_object( $this->_plugin ) )
{
/* Grab URL details */
$data = $this->deconstructUrl( $url );
/* Requires a permission check? */
if ( $data['data_app'] AND method_exists( $this->_plugin, 'requiresPermissionCheck' ) )
{
if ( $this->_plugin->requiresPermissionCheck( $data ) !== false )
{
$_file = IPSLib::getAppDir( $data['data_app'] ) . '/extensions/coreExtensions.php';
$_class = $data['data_app'] . 'ShareLinks';
$_result = false;
/* Check for the file */
if ( file_exists( $_file ) )
{
/* Get the file */
require_once( $_file );
/* Check for the class */
if ( class_exists( $_class ) )
{
/* Create an object */
$_obj = new $_class();
/* Check for the module */
if ( method_exists( $_obj, 'permissionCheck' ) )
{
if ( $_obj->permissionCheck( $data ) !== false )
{
$_result = true;
}
}
}
}
if ( $_result === false )
{
$this->registry->getClass('output')->showError('no_permission');
}
}
}
/* Log it */
$this->log( $url, $title, $data );
/* In almost all cases, there is no data to return as the plugin
redirects or posts an action */
$this->_plugin->share( $title, $url );
}
return false;
}
/**
* Init the plug in
*
* @access private
* @param string Plug in
*/
private function _initPlugin( $plugin='' )
{
$plugin = IPSText::alphanumericalClean( $plugin );
$parf = IPS_ROOT_PATH . 'sources/classes/share/plugins/';
$clarse = 'sl_' . $plugin;
/* Goddit? */
if ( file_exists( $parf . $plugin . '.php' ) )
{
require_once( $parf . $plugin . '.php' );
$this->_plugin = new $clarse( $this->registry );
}
else
{
throw new Exception( 'NO_SUCH_PLUGIN' );
}
}
/**
* Log a URL. Simple really.
*
* @access public
* @param string URL
* @return nufink
*/
public function deconstructUrl( $url )
{
/* init */
$data = array( 'data_app' => '',
'data_type' => '',
'data_primary_id' => 0,
'data_secondary_id' => 0 );
/* Try FURL first */
$ret = $this->_checkForFurl( $url );
if ( $ret === false OR ! count( $ret ) )
{
$ret = $this->_checkForApps( $this->_explodeUrl( $url ) );
}
else if ( is_array( $ret ) AND count( $ret ) AND ! $ret['app'] )
{
/* Is a shorter redirect based link, so use app processing... */
$_url = array();
foreach( $ret as $k => $v )
{
$_url[] = $k . '=' . $v;
}
$ret = $this->_checkForApps( $this->_explodeUrl( implode( '&', $_url ) ) );
}
/* Try again */
if ( is_array( $ret ) AND count( $ret ) AND $ret['data_app'] )
{
$data = $ret;
}
return $data;
}
/**
* Log a URL. Simple really.
*
* @access public
* @param string URL
* @return nufink
*/
public function log( $url, $title, $urlParts=array() )
{
/* If we're a 'bot, sod awf */
if ( $this->member->is_not_human )
{
return;
}
/* Ensure we're not jabbing our podgy fingers on the refresh button
We don't check the link 'cos you can any ?param on the end. member_id + share service should do */
if ( $this->memberData['member_id'] )
{
$check = $this->DB->buildAndFetch( array( 'select' => 'log_id',
'from' => 'core_share_links_log',
'where' => '(log_member_id=' . $this->memberData['member_id'] . ' OR log_ip_address=\'' . $this->member->ip_address . '\') AND log_share_key=\'' . $this->_pluginKey . '\' AND log_date > ' . ( time() - 60 ) ) );
}
else
{
$check = $this->DB->buildAndFetch( array( 'select' => 'log_id',
'from' => 'core_share_links_log',
'where' => 'log_ip_address=\'' . $this->member->ip_address . '\' AND log_share_key=\'' . $this->_pluginKey . '\' AND log_date > ' . ( time() - 60 ) ) );
}
if ( $check['log_id'] )
{
return;
}
/* Log */
$this->DB->insert( 'core_share_links_log', array( 'log_date' => time(),
'log_member_id' => $this->memberData['member_id'],
'log_url' => $url,
'log_title' => $title,
'log_ip_address' => $this->member->ip_address,
'log_share_key' => $this->_pluginKey,
'log_data_app' => $urlParts['data_app'],
'log_data_type' => $urlParts['data_type'],
'log_data_primary_id' => $urlParts['data_primary_id'],
'log_data_secondary_id' => $urlParts['data_secondary_id'] ) );
/* Rebuild caches */
$this->rebuildCaches();
}
/**
* Build some caches of stuff.
*
* @access public
*
*/
public function rebuildCaches()
{
/* INIT */
$caches = array( 'mostitems' => array(), 'mostrecent' => array(), 'mosttypes' => array() );
/* Delete caches */
$this->DB->delete( 'core_share_links_caches', "cache_key IN ('mostitems', 'mostrecent', 'mosttypes')" );
/* Most shared */
$this->DB->build( array( 'select' => 'COUNT(*) as count, log_data_app, log_data_type, log_data_primary_id',
'from' => 'core_share_links_log',
'group' => 'log_data_app, log_data_type, log_data_primary_id',
'order' => 'count DESC',
'limit' => array( 0, 10 ) ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$caches['mostitems'][] = $row;
}
/* Most recent shares */
$this->DB->build( array( 'select' => 'log_id, log_data_app, log_data_type, log_data_primary_id',
'from' => 'core_share_links_log',
'order' => 'log_date DESC',
'limit' => array( 0, 10 ) ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$caches['mostrecent'][] = $row;
}
/* Most used share type*/
$this->DB->build( array( 'select' => 'COUNT(*) as count, log_share_key',
'from' => 'core_share_links_log',
'group' => 'log_share_key',
'order' => 'count DESC',
'limit' => array( 0, 10 ) ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
$caches['mosttypes'][] = $row;
}
/* Save 'em */
foreach( $caches as $key => $data )
{
$this->DB->insert( 'core_share_links_caches', array( 'cache_key' => $key, 'cache_date' => time(), 'cache_data' => serialize( $data ) ) );
}
}
/**
* Try and deconstruct the link via app specific processing
*
* @access private
* @param array Array or URL bits
* @return array Array of request data or false
*/
private function _checkForApps( $url )
{
$app_cache = $this->cache->getCache('app_cache');
/* Loop through applications */
foreach( $app_cache as $app_dir => $app )
{
/* Only if app enabled... */
if ( $app['app_enabled'] )
{
/* Setup */
$_file = IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/coreExtensions.php';
$_class = $app['app_directory'] . 'ShareLinks';
/* Check for the file */
if( file_exists( $_file ) )
{
/* Get the file */
require_once( $_file );
/* Check for the class */
if( class_exists( $_class ) )
{
/* Create an object */
$_obj = new $_class();
/* Check for the module */
if( method_exists( $_obj, 'deconstructUrl' ) )
{
/* Call it */
$ret = $_obj->deconstructUrl( $url );
if ( is_array( $ret ) AND $ret['data_app'] )
{
return $ret;
}
}
}
}
}
}
return array( 'data_app' => '' );
}
/**
* Try and deconstruct the link if it's a FURRY FURL
*
* @access private
* @param string Incoming URL
* @return array Array of request data or false
*/
private function _checkForFurl( $url )
{
$_urlBits = array();
$_toTest = $url;
$templates = array();
/* Grab FURL data... */
if ( ! IN_DEV AND file_exists( DOC_IPS_ROOT_PATH . 'cache/furlCache.php' ) )
{
require( DOC_IPS_ROOT_PATH . 'cache/furlCache.php' );
$_seoTemplates = $templates;
}
else
{
/* Attempt to write it */
$_seoTemplates = IPSLib::buildFurlTemplates();
try
{
IPSLib::cacheFurlTemplates();
}
catch( Exception $e )
{
}
}
if ( is_array( $_seoTemplates ) AND count( $_seoTemplates ) )
{
foreach( $_seoTemplates as $key => $data )
{
if ( ! isset( $data['in']['regex'] ) OR ! $data['in']['regex'] )
{
continue;
}
if ( preg_match( $data['in']['regex'], $_toTest, $matches ) )
{
if ( is_array( $data['in']['matches'] ) )
{
foreach( $data['in']['matches'] as $_replace )
{
$k = IPSText::parseCleanKey( $_replace[0] );
if ( strpos( $_replace[1], '$' ) !== false )
{
$v = IPSText::parseCleanValue( $matches[ intval( str_replace( '$', '', $_replace[1] ) ) ] );
}
else
{
$v = IPSText::parseCleanValue( $_replace[1] );
}
$_urlBits[ $k ] = $v;
}
}
if ( strpos( $_toTest, $_seoTemplates['__data__']['varBlock'] ) !== false )
{
$_parse = substr( $_toTest, strpos( $_toTest, $_seoTemplates['__data__']['varBlock'] ) + strlen( $_seoTemplates['__data__']['varBlock'] ) );
$_data = explode( $_seoTemplates['__data__']['varSep'], $_parse );
$_c = 0;
foreach( $_data as $_v )
{
if ( ! $_c )
{
$k = IPSText::parseCleanKey( $_v );
$v = '';
$_c++;
}
else
{
$v = IPSText::parseCleanValue( $_v );
$_c = 0;
$_urlBits[ $k ] = $v;
}
}
}
break;
}
}
//-----------------------------------------
// If using query string furl, extract any
// secondary query string.
// Ex: http://localhost/index.php?/path/file.html?key=value
// Will pull the key=value properly
//-----------------------------------------
$_qmCount = substr_count( $_toTest, '?' );
if ( $_qmCount > 1 )
{
$_secondQueryString = substr( $_toTest, strrpos( $_toTest, '?' ) + 1 );
$_secondParams = explode( '&', $_secondQueryString );
if( count($_secondParams) )
{
foreach( $_secondParams as $_param )
{
list( $k, $v ) = explode( '=', $_param );
$k = IPSText::parseCleanKey( $k );
$v = IPSText::parseCleanValue( $v );
$_urlBits[ $k ] = $v;
}
}
}
/* Process URL bits for extra ? in them */
if ( is_array( $_urlBits ) AND count( $_urlBits ) )
{
foreach( $_urlBits as $k => $v )
{
if ( strstr( $v, '?') )
{
list( $rvalue, $more ) = explode( '?', $v );
if ( $rvalue AND $more )
{
/* Reset key with correct value */
$_v = $rvalue;
$_urlBits[ $k ] = $_v;
/* Now add in the other value */
if ( strstr( $more, '=' ) )
{
list( $_k, $_v ) = explode( '=', $more );
if ( $_k and $_v )
{
$_urlBits[ $_k ] = $_v;
}
}
}
}
}
}
}
return ( count($_urlBits) ) ? $_urlBits : false;
}
/**
* Explode a URL (foo=bar&baz=umm) into array( 'foo' => 'bar', .... )
*
* @access private
* @param string URL
* @return array Values
*/
private function _explodeUrl( $url )
{
$url = str_replace( '&amp;', '&', $url );
$ret = array();
if ( strstr( $url, '?' ) )
{
list( $_u, $url ) = explode( '?', $url );
}
foreach( explode( '&', $url ) as $bit )
{
list($k, $v) = explode( '=', $bit );
if ( $k and $v )
{
$ret[ trim( $k ) ] = trim( $v );
}
}
return $ret;
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.0 Beta 2
* Bobrdobr plug in for share links library.
* This is just the basic fallback bobrdobr share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_bobrdobr
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://bobrdobr.ru/addext.html?url=" . urlencode( $url ) . '&title=' . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_buzz
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Google
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://www.google.com/buzz/post?url=" . urlencode( $url ) . "&title=" . urlencode( $title ) . "&type=normal-count";
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_delicious
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://del.icio.us/post?v=2&url=" . urlencode( $url ) . "&title=" . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_digg
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://digg.com/submit?&url=" . urlencode( $url ) . "&title=" . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,105 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_download
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return true;
}
/**
* Redirect to Print
* Exciting, isn't it.
*
* @access private
* @param string Title
* @param string URL
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$_qmCount = substr_count( $url, '?' );
if ( $_qmCount > 0 )
{
#?/furl?s=xxxx
$url .= '&forceDownload=1';
}
else
{
$url .= '?forceDownload=1';
}
$url .= '&_k=' . $this->member->form_hash;
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_email
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return true;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$url = $this->settings['base_url'] . 'app=forums&module=extras&section=forward&url=' . IPSText::base64_encode_urlSafe( $url ) . '&title=' . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_facebook
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://www.facebook.com/sharer.php?u=" . urlencode( $url );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.0 Beta 2
* Memori plug in for share links library.
* This is just the basic fallback memori share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_memori
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://memori.ru/link/?sm=1&u_data[url]=" . urlencode( $url ) . '&u_data[name]=' . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,105 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_print
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return true;
}
/**
* Redirect to Print
* Exciting, isn't it.
*
* @access private
* @param string Title
* @param string URL
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$_qmCount = substr_count( $url, '?' );
if ( $_qmCount > 0 )
{
#?/furl?s=xxxx
$url .= '&forcePrint=1';
}
else
{
$url .= '?forcePrint=1';
}
$url .= '&_k=' . $this->member->form_hash;
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_reddit
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://reddit.com/submit?url=" . urlencode( $url ) . "&title=" . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,92 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_stumble
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://www.stumbleupon.com/submit?url=" . urlencode( $url ) . "&title=" . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter plug in for share links library.
* This is just the basic fallback twitter share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_twitter
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://twitter.com/home?status=" . urlencode( $title ) . '%20-%20' . urlencode( $url );
$this->registry->output->silentRedirect( $url );
}
}
@@ -0,0 +1,91 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.0 Beta 2
* Vkontakte plug in for share links library.
* This is just the basic fallback vkontakte share, the front end has JS to do something more fancy
*
* Created by Matt Mecham
* Last Updated: $Date: 2010-01-25 13:21:25 +0000 (Mon, 25 Jan 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 5746 $
*
*/
/* Class name must be in the format of:
sl_{key}
Where {key}, place with the value of: core_share_links.share_key
*/
class sl_vkontakte
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Construct.
* @access public
* @param object Registry
* @return void
*/
public function __construct( $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();
}
/**
* Requires a permission check
*
* @access public
* @param array Data array
* @return boolean
*/
public function requiresPermissionCheck( $array )
{
return false;
}
/**
* Redirect to Twitter
* Exciting, isn't it.
*
* @access private
* @param string Plug in
*/
public function share( $title, $url )
{
$title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' );
$url = "http://vkontakte.ru/share.php?url=" . urlencode( $url ) . '&title=' . urlencode( $title );
$this->registry->output->silentRedirect( $url );
}
}
+10 -1
View File
@@ -1 +1,10 @@
<html> <head><title>IP.Board - Bulletin Board System</title></head> <body> <h1>403: IP.Board -> Forbidden</h1> <hr> You have reached this page in error, please use your back button to return to the forum. <hr> <a href="http://www.invisionboard.com/">IP.Board</a> </body> </html>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
+326 -108
View File
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Skin Caching Functions
* Last Updated: $Date: 2009-10-01 10:02:08 -0400 (Thu, 01 Oct 2009) $
* Last Updated: $Date: 2010-10-14 06:42:56 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* Owner: Matt
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th July 2008
* @version $Revision: 5190 $
* @version $Revision: 6975 $
*
*/
@@ -91,7 +93,14 @@ class skinCaching extends skinFunctions
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
else
{
array_unshift( $skinSetData['_childTree'], 0 );
}
//-----------------------------------------
// Remove current caches
@@ -105,6 +114,13 @@ class skinCaching extends skinFunctions
foreach( $skinSetData['_childTree'] as $_setID )
{
/* Bit of a fiddle here... */
if ( ! is_numeric( $setID ) AND $_setID == 0 )
{
/* We mean a master set, then */
$_setID = $setID;
}
$__replacements = $this->fetchReplacements( $_setID );
$_replacements = array();
@@ -119,6 +135,8 @@ class skinCaching extends skinFunctions
'cache_set_id' => $_setID,
'cache_type' => 'replacements',
'cache_content' => serialize( $_replacements ) ) );
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
return TRUE;
@@ -140,6 +158,12 @@ class skinCaching extends skinFunctions
$skinSetData = $this->fetchSkinData( $setID );
$skinSetData['set_image_dir'] = ( $skinSetData['set_image_dir'] ) ? $skinSetData['set_image_dir'] : 'master';
/* These are not always set up correctly */
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinSetData['set_image_dir'];
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
/* Remove dead template caches */
$this->removeDeadPHPCaches( $setID );
@@ -165,8 +189,15 @@ class skinCaching extends skinFunctions
$groupTitles = $this->fetchTemplates( $_setID, 'groupNames' );
$allHooks = $this->fetchSkinHooks();
/* Update DB row */
$this->DB->update( 'skin_collections', array( 'set_updated' => time() ), 'set_id=' . intval( $_setID ) );
foreach ( $groupTitles as $name => $group )
{
/* Separated $out into two variables, needed to build the sections independently to fix bug #21574 */
$fileHead = '';
$fileBody = '';
//-----------------------------------------
// Skip if we're only updating one group..
//-----------------------------------------
@@ -179,8 +210,8 @@ class skinCaching extends skinFunctions
}
}
$out = "class {$group['template_group']}_{$_setID} {\n\n";
$out .= <<<EOF
$fileHead = "class {$group['template_group']}_{$_setID} {\n\n";
$fileHead .= <<<EOF
/**
* Construct
*/
@@ -196,21 +227,37 @@ function __construct( ipsRegistry \$registry )
\$this->memberData =& \$this->registry->member()->fetchMemberData();
\$this->cache = \$this->registry->cache();
\$this->caches =& \$this->registry->cache()->fetchCaches();
}
EOF;
$templates = $this->fetchTemplates( $_setID, 'groupTemplates', $group['template_group'] );
foreach ($templates as $func_name => $data )
{
$this->registry->templateEngine->setWorkingGroup( $group['template_group'] );
$out .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
$fileBody .= $this->registry->templateEngine->convertHtmlToPhp( $data['template_name'], $data['template_data'], $data['template_content'] ) ."\n";
}
$out .= "\n\n}";
//-----------------------------------------
// Function Hooks
//------------------------------------------
$funcHooks = '$this->_funcHooks = array();' . "\n";
if( is_array( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] ) )
{
foreach( $this->registry->templateEngine->_hookIds[ $group['template_group'] ] as $func_name => $hookIds )
{
if( is_array( $hookIds ) && count( $hookIds ) )
{
$funcHooks .= "\$this->_funcHooks['{$func_name}'] = array(".implode( ',', $hookIds ).");\n";
}
}
}
$fileHead .= "\n\n{$funcHooks}\n\n}\n\n";
$out = $fileHead . $fileBody . "\n}\n";
/* This would be better off within the templateEngine really cos $out now contains the entire class */
$out = $this->stripUnneededHooks( $out, $allHooks[ $group['template_group'] ] );
@@ -226,6 +273,7 @@ EOF;
'cache_key_1' => 'group',
'cache_value_1' => $group['template_group'],
'cache_content' => $out ) );
//-----------------------------------------
// Write to the flatfile
@@ -235,7 +283,7 @@ EOF;
$start .= "/*--------------------------------------------------*/\n";
$start .= "/* FILE GENERATED BY INVISION POWER BOARD 3 */\n";
$start .= "/* CACHE FILE: Skin set id: {$_setID} */\n";
$start .= "/* CACHE FILE: Generated: ".gmdate( "D, d M Y H:i:s \G\M\T" )." */\n";
$start .= "/* CACHE FILE: Generated: ".gmdate( 'D, d M Y H:i:s \G\M\T' )." */\n";
$start .= "/* DO NOT EDIT DIRECTLY - THE CHANGES WILL NOT BE */\n";
$start .= "/* WRITTEN TO THE DATABASE AUTOMATICALLY */\n";
$start .= "/*--------------------------------------------------*/\n\n";
@@ -249,11 +297,16 @@ EOF;
{
$this->_writePHPTemplate( $_setID, $group['template_group'], $start.$out.$end );
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
$this->_addMessage( "HTML шаблоны обновлены... (Стиль: $_setID)" );
$this->_addMessage( sprintf( $this->lang->words['finishedcachinghtml'], $_setID ) );
}
/* Rebuild skin cache */
$this->rebuildSkinSetsCache();
return TRUE;
}
@@ -273,7 +326,7 @@ EOF;
$phpKeep = array();
$phpThrow = array();
$phpUnlink = array();
//-----------------------------------------
// Get skin set data
//-----------------------------------------
@@ -310,8 +363,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_cache',
'where' => 'cache_type=\'phptemplate\'',
'order' => 'cache_set_id ASC' ) );
'where' => "cache_type='phptemplate' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
$this->DB->execute();
@@ -338,7 +390,7 @@ EOF;
foreach( $phpKeep as $_setID => $data )
{
$_path = IPS_CACHE_PATH.'cache/skin_cache/cacheid_' . $_setID;
$_path = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $_setID;
if ( is_dir( $_path ) )
{
@@ -433,8 +485,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_cache',
'where' => 'cache_type=\'css\'',
'order' => 'cache_set_id ASC' ) );
'where' => "cache_type='css' AND cache_set_id IN (" . implode( ",", $tree ) . ")" ) );
$this->DB->execute();
@@ -486,6 +537,8 @@ EOF;
}
} catch ( Exception $e ) {}
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
//-----------------------------------------
@@ -546,7 +599,10 @@ EOF;
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
//-----------------------------------------
// Fetch CSS that needs to be rebuilt
@@ -639,7 +695,10 @@ EOF;
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_childTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_childTree'], $setID );
}
//-----------------------------------------
// Fetch CSS that needs to be rebuilt
@@ -655,7 +714,8 @@ EOF;
foreach( array_keys( $needToRebuild ) as $_setID )
{
$_css = $this->fetchCSS( $_setID );
$_css = $this->fetchCSS( $_setID );
$_skinSetData = $this->fetchSkinData( $_setID );
foreach( $_css as $name => $css )
{
@@ -685,8 +745,12 @@ EOF;
'cache_value_5' => $css['css_attributes'],
'cache_key_6' => 'modules',
'cache_value_6' => $css['css_modules'],
'cache_content' => $this->_CSS_fromDBtoFile( $css['css_content'], $skinSetData ) ) );
'cache_content' => $this->_CSS_fromDBtoFile( $css['css_content'], $_skinSetData )
//'cache_content' => $css['css_content']
) ) ;
}
$this->cache->putWithCacheLib( 'Skin_Store_' . $_setID, array(), 1 );
}
//-----------------------------------------
@@ -725,6 +789,8 @@ EOF;
foreach( $cssSkinCollections as $setID => $data )
{
$this->DB->update( 'skin_collections', array( 'set_css_groups' => serialize( $cssSkinCollections[ $setID ] ) ), 'set_id='. $setID );
$this->cache->putWithCacheLib( 'Skin_Store_' . $setID, array(), 1 );
}
}
@@ -740,13 +806,18 @@ EOF;
* @access public
* @return bool
*/
public function rebuildMasterReplacements()
public function rebuildMasterReplacements( $setId=0 )
{
/* Set directory */
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$dir = IPS_CACHE_PATH . 'cache/skin_cache/' . $this->remapData['templates'][ $setId ];
$messages = array();
//-----------------------------------------
// Master file exists?
//-----------------------------------------
if ( ! file_exists( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' ) )
if ( ! file_exists( $dir . '/_replacements.inc' ) )
{
return FALSE;
}
@@ -755,15 +826,19 @@ EOF;
// Remove current CSS
//-----------------------------------------
$this->DB->delete( 'skin_replacements', "replacement_set_id=0" );
if ( ! is_numeric( $setId ) )
{
$this->DB->delete( 'skin_replacements', "replacement_master_key='" . $setId . "'" );
}
//-----------------------------------------
// Grab file
//-----------------------------------------
require( IPS_CACHE_PATH . 'cache/skin_cache/master_skin/_replacements.inc' );
$replacements = array();
require( $dir . '/_replacements.inc' );
if ( ! count( $replacements ) )
if ( !is_array($replacements) || !count($replacements) )
{
return FALSE;
}
@@ -771,13 +846,18 @@ EOF;
/* Insert... */
foreach( $replacements as $k => $v )
{
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
'replacement_content' => $v,
'replacement_set_id' => 0,
'replacement_added_to' => 0 ) );
$messages[] = $this->lang->words['basicimportedpre'] . $k;
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $k,
'replacement_content' => $v,
'replacement_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
'replacement_set_id' => 0,
'replacement_added_to' => 0 ) );
}
return TRUE;
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
return $messages;
}
/**
@@ -793,6 +873,7 @@ EOF;
public function rebuildMasterCSS( $setId=0 )
{
/* Set directory */
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$cssDir = DOC_IPS_ROOT_PATH . 'public/style_css/' . $this->remapData['css'][ $setId ];
$messages = array();
$css = array();
@@ -813,18 +894,22 @@ EOF;
throw new Exception( "CANNOT_READ" );
}
/* Fetch all CSS bits. NOW */
if ( $setId > 0 )
/* Remove current CSS... */
if ( is_numeric( $setId ) )
{
$this->DB->delete( 'skin_css', 'css_set_id=' . $setId );
}
else
{
$this->DB->delete( 'skin_css', 'css_master_key=\'' . $setId . '\'' );
}
/* Fetch all template bits. NOW */
if ( is_numeric( $setId ) AND $setId > 0 )
{
$css = $this->fetchCSS( $setId );
}
//-----------------------------------------
// Remove current CSS
//-----------------------------------------
$this->DB->delete( 'skin_css', "css_set_id=" . $setId );
//-----------------------------------------
// Recurse over the directory
//-----------------------------------------
@@ -845,8 +930,8 @@ EOF;
/* Encode */
$cssContent = IPSText::encodeForXml( $cssContent );
$messages[] = "Imported " . $cssName;
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
@@ -858,13 +943,14 @@ EOF;
}
$this->DB->insert( 'skin_css', array( 'css_updated' => time(),
'css_set_id' => $setId,
'css_added_to' => $_css_added_to,
'css_set_id' => ( is_numeric( $setId ) ) ? $setId : $this->fetchSetIdByKey( $setId ),
'css_added_to' => ( is_numeric( $_css_added_to ) ) ? $_css_added_to : $this->fetchSetIdByKey( $_css_added_to ),
'css_app' => $cssData['css_app'],
'css_app_hide' => intval( $cssData['css_app_hide'] ),
'css_modules' => trim( $cssData['css_modules'] ),
'css_position' => intval( $cssData['css_position'] ),
'css_attributes' => $cssData['css_attributes'],
'css_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
'css_group' => $cssName,
'css_content' => $cssContent ) );
}
@@ -873,10 +959,12 @@ EOF;
} catch ( Exception $e ) {}
/* Recache */
if ( $setId )
if ( is_numeric( $setId ) AND $setId )
{
$this->rebuildCSS( $setId );
$this->removeDeadCSSCaches( $setId );
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
}
return $messages;
@@ -901,7 +989,7 @@ EOF;
// INIT
//-----------------------------------------
$setId = intval( $setId );
$setId = is_numeric( $setId ) ? intval( $setId ) : trim( $setId );
$script_token = 0;
$script_jump = 0;
$skin_dir = IPS_CACHE_PATH . "cache/skin_cache/" . $this->remapData['templates'][ $setId ];
@@ -926,10 +1014,17 @@ EOF;
}
/* Remove current templates... */
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
if ( is_numeric( $setId ) )
{
$this->DB->delete( 'skin_templates', 'template_set_id=' . $setId );
}
else
{
$this->DB->delete( 'skin_templates', 'template_master_key=\'' . $setId . '\'' );
}
/* Fetch all template bits. NOW */
if ( $setId > 0 )
if ( is_numeric( $setId ) AND $setId > 0 )
{
$templates = $this->fetchTemplates( $setId, 'allTemplates' );
}
@@ -937,7 +1032,7 @@ EOF;
/* Loop through the directory */
try
{
foreach( new DirectoryIterator( $skin_dir ) as $file )
foreach( new DirectoryIterator( $skin_dir ) as $file )
{
if ( ! $file->isDot() AND ! $file->isDir() )
{
@@ -950,7 +1045,7 @@ EOF;
if ( ! $fdata )
{
$messages[] = "Не удалось открыть файл $_name, пропускаем...";
$messages[] = sprintf( $this->lang->words['couldnotopenfile'], $_name );
continue;
}
@@ -959,7 +1054,7 @@ EOF;
if ( ! preg_match( "/\n/", $fdata ) )
{
$messages[] = "Не удалось найти содержимое в файле $_name, пропускаем...";
$messages[] = sprintf( $this->lang->words['couldnotfindlineeol'], $_name );
continue;
}
@@ -992,7 +1087,7 @@ EOF;
if ( $script_token AND $script_jump == 0 )
{
if ( preg_match( "#<if test=[\'\"]#", $f ) )
if ( preg_match( '#<if test=[\'\"]#', $f ) )
{
$script_jump = 1;
$script_token = 0;
@@ -1014,7 +1109,7 @@ EOF;
if ( ! $script_token )
{
if ( preg_match( "/^function\s*([\w\_]+)\s*\((.*)\)/i", $f, $matches ) )
if ( preg_match( '/^function\s*([\w\_]+)\s*\((.*)\)/i', $f, $matches ) )
{
$functions[ $matches[1] ] = '';
$config[ $matches[1] ] = $matches[2];
@@ -1028,9 +1123,9 @@ EOF;
else
{
# Make JS safe (UBE - Ugly, but effective)
$f = preg_replace( "#if\s+?\(#is" , "i~f~(~" , $f );
$f = str_ireplace( "else" , "e~lse~" , $f );
$f = preg_replace( "#else\s+?if#is", "e~lse~i~f", $f );
$f = preg_replace( '#if\s+?\(#is' , "i~f~(~" , $f );
$f = str_ireplace( 'else' , "e~lse~" , $f );
$f = preg_replace( '#else\s+?if#is', "e~lse~i~f", $f );
}
if ( $flag )
@@ -1061,14 +1156,15 @@ EOF;
$content = IPSText::encodeForXml( $content );
/* Build array */
$array = array( 'template_set_id' => $setId,
'template_group' => $name,
'template_content' => $content,
'template_name' => $fname,
'template_data' => trim($config[$fname]),
'template_updated' => time(),
'template_removable' => ( $setId ) ? 1 : 0,
'template_added_to' => $setId );
$array = array( 'template_set_id' => $setId,
'template_group' => $name,
'template_content' => $content,
'template_name' => $fname,
'template_data' => trim($config[$fname]),
'template_updated' => time(),
'template_removable' => ( is_numeric( $setId ) AND $setId ) ? 1 : 0,
'template_master_key' => ( is_numeric( $setId ) ) ? $this->fetchSetKeyById( $setId ) : $setId,
'template_added_to' => ( is_numeric( $setId ) ) ? intval( $setId ) : $this->fetchSetIdByKey( $setId ) );
if ( ! $setId OR ! $templates[ $name ][ strtolower( $fname ) ] )
{
@@ -1090,25 +1186,51 @@ EOF;
}
}
$messages[] = "$name добавлен (Шаблонов добавлено " . $added . "; обновлено " . $updated . ")";
$messages[] = sprintf( $this->lang->words['tplbitimported'], $name, $added, $updated );
$functions = array();
}
}
}
} catch ( Exception $e ) {}
/* Recache */
if ( $setId )
if ( is_numeric( $setId ) AND $setId )
{
$this->rebuildPHPTemplates( $setId );
$this->removeDeadPHPCaches( $setId );
$this->cache->putWithCacheLib( 'Skin_Store_' . $setId, array(), 1 );
}
/* Return */
$messages[] = "Завершено обновление шаблонов из PHP кеша.";
$messages[] = $this->lang->words['cpltrebuildfromcaches'];
return $messages;
}
/**
* Flag skin as needing recache
*
* @access public
* @return boolean
*/
public function flagSetForRecache( $setId=null )
{
/* Update DB row */
if ( $setId !== null )
{
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ), 'set_id=' . intval( $setId ) );
}
else
{
$this->DB->update( 'skin_collections', array( 'set_updated' => -1 ) );
}
/* Build cache */
$this->rebuildSkinSetsCache();
return TRUE;
}
/**
* Rebuild skinsets cache in the cache_store table
*
@@ -1129,7 +1251,7 @@ EOF;
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'order' => 'set_parent_id, set_id' ) );
'order' => 'set_order' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
@@ -1235,7 +1357,7 @@ EOF;
$cssContent = str_replace( array( "\r\n", "\r" ), "\n", $cssContent );
$messages[] = "Импортирован " . $cssName;
$messages[] = $this->lang->words['basicimportedpre'] . $cssName;
$cssData = $this->_CSS_fetchImportBlock( $cssContent );
$cssContent = $this->_CSS_fromFileToDB( $cssContent );
@@ -1280,6 +1402,11 @@ EOF;
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = DOC_IPS_ROOT_PATH . 'public/style_css/' . $dir;
@@ -1312,11 +1439,11 @@ EOF;
if ( @file_put_contents( $path . '/' . $data['css_group'] . '.css', $_block . $this->_CSS_fromDBtoFile( $data['css_content'], $setData ) ) )
{
$msgs[] = "Записан: " . $data['css_group'] . '.css';
$msgs[] = $this->lang->words['basicwrittenpre'] . $data['css_group'] . '.css';
}
else
{
$msgs[] = "Ошибка: Не удалось записать " . $data['css_group'] . '.css';
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $data['css_group'] . '.css';
}
}
}
@@ -1324,6 +1451,81 @@ EOF;
return $msgs;
}
/**
* Write out replacements in the master format
* IN_DEV tool, currently.
*
* @access public
* @param int Skin ID to write out
* @param string Directory to write into. Directory must be in /public/style_css/
* @return array Array of messages
* Exception Codes:
* IN_DEV_OFF IN_DEV constant is not enabled
* NO_SUCH_SKIN_SET Skin set of $id does not exist
* DIR_DOES_NOT_EXIST Directory does not exist in /cache/skin_cache
* CANNOT_WRITE_DIR Directory cannot be written into
*/
public function writeMasterSkinReplacements( $id, $dir )
{
/* Checkin' */
if ( ! IN_DEV )
{
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
$msgs = array();
if ( ! isset( $setData['set_id'] ) )
{
throw new Exception( 'NO_SUCH_SKIN_SET' );
}
if ( ! is_dir( $path ) )
{
throw new Exception( 'DIR_DOES_NOT_EXIST' );
}
if ( ! is_writeable( $path ) )
{
throw new Exception( 'CANNOT_WRITE_DIR' );
}
/* Fetch Replacements */
$replacements = $this->fetchReplacements( $id );
/* Write it.. */
if ( is_array( $replacements ) )
{
$content = "<" . "?php\n\n\$replacements = array(\n\n";
foreach( $replacements as $k => $data )
{
$content .= "\n'" . $k . "' => \"" . str_replace( '"', '\\"', $data['replacement_content'] ) . '",';
}
$content .= "\n);\n\n?>";
if ( @file_put_contents( $path . '/_replacements.inc', $content ) )
{
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/_replacements.inc';
}
else
{
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/_replacements.inc';
}
}
return $msgs;
}
/**
* Write out skin templates in the master format
* IN_DEV tool, currently.
@@ -1346,6 +1548,11 @@ EOF;
throw new Exception( 'IN_DEV_OFF' );
}
if ( ! is_numeric( $id ) )
{
$id = $this->fetchSetIdByKey( $id );
}
$setData = $this->fetchSkinData( $id );
$path = IPS_CACHE_PATH . 'cache/skin_cache/' . $dir;
@@ -1386,17 +1593,17 @@ EOF;
if ( ! @file_put_contents( $path . '/' . $_file, $_content ) )
{
$msgs[] = "Ошибка: Не удалось записать: " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basiccouldnotwrite'] . $path . '/' . $_file;
}
else
{
@chmod( $path . '/' . $_file, 0777 );
$msgs[] = "Записан: " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basicwrittenpre'] . $path . '/' . $_file;
}
}
else
{
$msgs[] = "Ошибка: нечего записывать в файл " . $path . '/' . $_file;
$msgs[] = $this->lang->words['basicnothingtowritepre'] . $path . '/' . $_file;
}
}
@@ -1424,6 +1631,11 @@ EOF;
$block[] = "<css_app>" . $data['css_app'] . "</css_app>";
}
if ( isset( $data['css_modules'] ) )
{
$block[] = "<css_modules>" . $data['css_modules'] . "</css_modules>";
}
if ( isset( $data['css_app_hide'] ) )
{
$block[] = "<css_app_hide>" . $data['css_app_hide'] . "</css_app_hide>";
@@ -1526,36 +1738,36 @@ EOF;
{
$good_to_go = 1;
if ( is_writeable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
if ( is_writeable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/' ) === TRUE )
{
$good_to_go = 1;
if ( ! is_dir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) )
if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) )
{
if ( ! @ mkdir( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 ) )
if ( ! @ mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID, 0777 ) )
{
$this->_addErrorMessage( "Ошибка! не удалось создать: public/style_css/css_{$setID}/" );
$this->_addErrorMessage( sprintf( $this->lang->words['couldnotcreatecssdir'], $setID ) );
return $this->_errorMsgs;
}
else
{
@file_put_contents( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
@chmod( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
@file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID . '/index.html', '' );
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID, 0777 );
$good_to_go = 1;
}
}
else
{
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID ) !== TRUE )
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID ) !== TRUE )
{
$this->_addErrorMessage( "public/style_css/css_{$setID}/ not writeable" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssdirnotwritaaaable'], $setID ) );
$good_to_go = 0;
}
else if ( file_exists( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
else if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) )
{
if ( is_writable( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
if ( is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css' ) !== TRUE )
{
$this->_addErrorMessage( "public/style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
$good_to_go = 0;
}
else
@@ -1571,13 +1783,13 @@ EOF;
}
else
{
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . PUBLIC_DIRECTORY . "/style_css нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotwreite'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY ) );
$good_to_go = 0;
}
}
else
{
$this->_addErrorMessage( "Безопасный режим: Пропускаем создание CSS кешей" );
$this->_addErrorMessage( $this->lang->words['safemodeenablednow'] );
$good_to_go = 0;
}
@@ -1587,17 +1799,17 @@ EOF;
if ( $good_to_go )
{
if ( $FH = @fopen( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
if ( $FH = @fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 'w' ) )
{
fwrite( $FH, $css_content, strlen($css_content) );
fclose( $FH );
@chmod( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 0777 );
@chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_'.$setID.'/'.$css_group.'.css', 0777 );
$this->_addMessage( "Записан skin_cache/css_{$setID}/{$css_group}.css" );
$this->_addMessage( $this->lang->words['basicwrittenpre']. "skin_cache/css_{$setID}/{$css_group}.css" );
}
else
{
$this->_addErrorMessage( "style_css/css_{$setID}/{$css_group}.css нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['cssfilenotwriteable'], $setID, $css_group ) );
}
}
}
@@ -1632,7 +1844,7 @@ EOF;
{
if ( ! @ mkdir( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID, 0777 ) )
{
$this->_addErrorMessage( "Ошибка! не удалось создать: cache/skin_cache/cacheid_{$setID}/" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplatew'], $setID ) );
return;
}
else
@@ -1648,7 +1860,7 @@ EOF;
{
if ( IPSLib::isWritable( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php' ) !== TRUE )
{
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
$good_to_go = 0;
}
else
@@ -1664,7 +1876,7 @@ EOF;
}
else
{
$this->_addErrorMessage( "Ошибка! " . IPS_CACHE_PATH . "cache/skin_cache нет прав на запись - измените права записи на директорию или переключите стили в безопасный режим" );
$this->_addErrorMessage( sprintf( $this->lang->words['fatalnotemplsafe'], IPS_CACHE_PATH ) );
}
}
@@ -1680,11 +1892,11 @@ EOF;
fclose( $FH );
@chmod( IPS_CACHE_PATH.'cache/skin_cache/cacheid_'.$setID.'/'.$groupName.'.php', 0777 );
$this->_addMessage( "Записан skin_cache/cacheid_{$setID}/{$groupName}.php" );
$this->_addMessage( $this->lang->words['basicwrittenpre'] . "skin_cache/cacheid_{$setID}/{$groupName}.php" );
}
else
{
$this->_addErrorMessage( "cache/skin_cache/cacheid_{$setID}/{$groupName}.php нет прав на запись" );
$this->_addErrorMessage( sprintf( $this->lang->words['templatefilenowrite'], $setID, $groupName ) );
}
}
}
@@ -1711,7 +1923,7 @@ EOF;
}
/* Remove all hooks */
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
/* Restore saved hooks */
foreach( $hooks as $hook )
@@ -1725,7 +1937,7 @@ EOF;
else
{
/* No hooks, so remove all */
$html = preg_replace( "#<!--hook\.([^\>]+?)-->#", '', $html );
$html = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $html );
}
return $html;
@@ -1752,7 +1964,7 @@ EOF;
/* Fetch the data block */
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
{
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
if ( $match[0] )
{
@@ -1788,7 +2000,7 @@ EOF;
/* Fetch the data block */
if ( strstr( $cssContent, '<IPS_IMPORT_BLOCK>' ) )
{
preg_match( "#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is", $cssContent, $match );
preg_match( '#/\*<IPS_IMPORT_BLOCK>(.+?)</IPS_IMPORT_BLOCK>\*/#is', $cssContent, $match );
if ( $match[0] )
{
@@ -1797,8 +2009,8 @@ EOF;
}
}
$cssContent = preg_replace( "#url\((\"|')?.+?style_images/([\d\w]+?)/#i", "url(\\1{style_images_url}/", $cssContent );
$cssContent = preg_replace( "#url\((\"|')?/style_images/([\d\w]+?)#i" , "url(\\1{style_images_url}/", $cssContent );
$cssContent = preg_replace( '#url\((\"|\')?.+?style_images/([\d\w]+?)/#i', "url(\\1{style_images_url}/", $cssContent );
$cssContent = preg_replace( '#url\((\"|\')?/style_images/([\d\w]+?)#i' , "url(\\1{style_images_url}/", $cssContent );
return $cssContent;
}
@@ -1814,6 +2026,10 @@ EOF;
{
$skinData['set_image_dir'] = ( $skinData['set_image_dir'] ) ? $skinData['set_image_dir'] : 'master';
/* These are not always set up correctly */
$this->settings['img_url'] = ( $this->settings['img_url'] ) ? $this->settings['img_url'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/' . $skinData['set_image_dir'];
$this->settings['img_url_no_dir'] = ( $this->settings['img_url_no_dir'] ) ? $this->settings['img_url_no_dir'] : $this->settings['_original_base_url'] . '/' . PUBLIC_DIRECTORY . '/style_images/';
//-----------------------------------------
// Fix up style images stuff
//-----------------------------------------
@@ -1832,7 +2048,7 @@ EOF;
$this->settings['ipb_img_url'] .= '/';
}
$cssContent = preg_replace( "#url\(('|\")?\.\./\.\./style_images/#", "url(\\1{$this->settings['ipb_img_url']}/style_images/", $cssContent );
$cssContent = preg_replace( '#url\((\'|\")?\.\./\.\./style_images/#', "url(\\1" . $this->settings['ipb_img_url'] . "/style_images/", $cssContent );
}
//-----------------------------------------
@@ -1867,7 +2083,9 @@ EOF;
return $this->_cssNeedToRebuildArray[ $setID ];
}
$needToRebuild = array();
$cachedCSS = array();
$thisCSS = array();
$needToRebuild = array();
//-----------------------------------------
// Fetch cached CSS data
File diff suppressed because it is too large. Load diff
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Skin Functions
* Last Updated: $Date: 2009-12-07 21:57:46 -0500 (Mon, 07 Dec 2009) $
* Last Updated: $Date: 2010-10-13 14:43:52 -0400 (Wed, 13 Oct 2010) $
* </pre>
*
* Owner: Matt
* @author $Author: bfarber $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5529 $
* @version $Revision: 6972 $
*
*/
@@ -81,6 +83,12 @@ class skinFunctions
*/
public $remapData = array();
/**
* Set cache
* @var private
*/
private $_seenSet = array();
/**
* Constructor
*
@@ -102,6 +110,9 @@ class skinFunctions
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->lang = $this->registry->class_localization;
$this->registry->class_localization->loadLanguageFile( array( 'admin_templates' ), 'core' );
//-----------------------------------------
// IN_DEV on?
@@ -137,6 +148,111 @@ class skinFunctions
return $this->recursiveTiers;
}
/**
* Fetch highest order
*
* @access public
* @return int
*/
public function fetchHighestSetPosition()
{
$bill = $this->DB->buildAndFetch( array( 'select' => 'MAX(set_order) as and_ted',
'from' => 'skin_collections' ) );
/* Excellent! (guitar solo) */
return intval( $bill['and_ted'] );
}
/**
* Can we use the merge system?
*
* @access public
* @return int
*/
public function canUseMergeSystem()
{
$c = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as ount',
'from' => 'skin_templates_previous' ) );
return ( $c['ount'] ) ? true : false;
}
/**
* Fetch master template keys
*
* @access public
* @return arraya
*/
public function fetchMasterKeys()
{
if ( is_array( $this->remapData ) AND is_array( $this->remapData['masterKeys'] ) )
{
return $this->remapData['masterKeys'];
}
else
{
$REMAP = array();
require( DOC_IPS_ROOT_PATH . 'cache/skin_cache/masterMap.php' );
if ( is_array($REMAP) && count($REMAP) )
{
$this->remapData = array( 'masterKeys' => $REMAP['masterKeys'] );
}
}
return $this->remapData['masterKeys'];
}
/**
* Returns a skin set ID based on a key
* @param string $key
*/
public function fetchSetIdByKey( $key )
{
$masterKeys = $this->fetchMasterKeys();
if ( in_array( $key, $masterKeys ) )
{
/* Default master keys are always 0 */
return 0;
}
if ( ! $this->_seenSet[ 'k-' . $key ] )
{
$this->_seenSet[ 'k-' . $key ] = $this->DB->buildAndFetch( array( 'select' => 'set_id',
'from' => 'skin_collections',
'where' => 'set_key=\'' . addslashes( $key ) . '\'' ) );
}
return ( $this->_seenSet[ 'k-' . $key ]['set_id'] ) ? $this->_seenSet[ 'k-' . $key ]['set_id'] : 0;
}
/**
* Returns a skin set key based on a id
* @param string $key
*/
public function fetchSetKeyById( $id )
{
$masterKeys = $this->fetchMasterKeys();
if ( $id == 0 )
{
/* Default master keys are always 0 */
return '';
}
if ( ! $this->_seenSet[ 'i-' . $id ] )
{
$this->_seenSet[ 'i-' . $id ] = $this->DB->buildAndFetch( array( 'select' => 'set_key',
'from' => 'skin_collections',
'where' => 'set_id=' . intval( $id ) ) );
}
return ( $this->_seenSet[ 'i-' . $id ]['set_key'] ) ? $this->_seenSet[ 'i-' . $id ]['set_key'] : 0;
}
/**
* Search template bits
*
@@ -201,7 +317,9 @@ class skinFunctions
{
return $return;
}
$_templateCount = 0;
/* You may continue... */
foreach( $_templates as $_group => $_gdata )
{
@@ -380,7 +498,9 @@ class skinFunctions
$this->remapData = $this->registry->output->buildRemapData();
}
$_dir = $this->remapData['templates'][ $id ];
$_id = ( $id == 0 ) ? $this->remapData['inDevDefault'] : $id;
$_dir = $this->remapData['templates'][ $_id ];
if( ! file_exists(IPS_CACHE_PATH."cache/skin_cache/" . $_dir . "/".$name.".php") )
{
@@ -440,7 +560,7 @@ class skinFunctions
}
/* Root skin? */
if ( in_array( $setID, array_values( $this->remapData['export'] ) ) )
if ( in_array( $setID, $this->remapData['masterKeys'] ) )
{
return FALSE;
}
@@ -492,18 +612,36 @@ class skinFunctions
$this->DB->delete( 'skin_url_mapping', 'map_skin_set_id=' . $setID );
/* Delete CSS Files */
$this->registry->adminFunctions->removeDirectory( IPS_CACHE_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
$this->registry->adminFunctions->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_css/css_' . $setID );
/* Delete PHP Cache Files */
$this->registry->adminFunctions->removeDirectory( IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $setID );
/* Delete any diff/merge sessions */
$this->DB->build( array( 'select' => '*',
'from' => 'skin_merge_session',
'where' => 'merge_set_id=' . $setID ) );
$o = $this->DB->execute();
while( $row = $this->DB->fetch( $o ) )
{
/* Delete 'em */
$this->DB->delete('skin_merge_session', 'merge_id=' . $row['merge_id'] );
$this->DB->delete('skin_merge_changes', 'change_session_id=' . $row['merge_id'] );
}
/* Rebuild Tree Information */
$this->rebuildTreeInformation();
/* Rebuild Skin Set Caches */
$this->rebuildSkinSetsCache();
$this->rebuildURLMapCache();
if ( class_exists( 'skinCaching' ) )
{
$this->rebuildSkinSetsCache();
$this->rebuildURLMapCache();
$this->cache->putWithCacheLib( 'Skin_Store_' . $setID, array(), 1 );
}
return TRUE;
}
@@ -540,10 +678,47 @@ class skinFunctions
{
$_parents = $this->recursiveTiers->fetchItemParents( $row['set_id'] );
$_children = $this->recursiveTiers->fetchItemChildren( $row['set_id'] );
$this->DB->update( 'skin_collections', array( 'set_parent_array' => serialize( ( is_array( $_parents ) ) ? $_parents : array() ),
'set_child_array' => serialize( ( is_array( $_children ) ) ? $_children : array() ) ), 'set_id=' . $row['set_id'] );
/* Reset master key - parents */
if( count($_parents) AND $row['set_id'] )
{
$_p = $_parents;
$_id = array_pop( $_p );
$rootParent = $this->fetchSkinData( $_id, true );
/* If no parent, we must be a parent, then */
if ( ! $rootParent['set_id'] )
{
$rootParent = $this->fetchSkinData( $setID, true );
}
$this->DB->update( 'skin_collections', array( 'set_master_key' => ( $rootParent['set_master_key'] ) ? $rootParent['set_master_key'] : 'root' ), 'set_id IN (' . implode( ',', $_parents ) . ')' );
}
/* Reset master key - children */
if( count($_children) AND $row['set_id'] )
{
if ( ! is_array( $rootParent ) )
{
$_p = $_parents;
$_id = array_pop( $_p );
$rootParent = $this->fetchSkinData( $_id, true );
/* If no parent, we must be a parent, then */
if ( ! $rootParent['set_id'] )
{
$rootParent = $this->fetchSkinData( $setID, true );
}
}
$this->DB->update( 'skin_collections', array( 'set_master_key' => ( $rootParent['set_master_key'] ) ? $rootParent['set_master_key'] : 'root' ), 'set_id IN (' . implode( ',', $_children ) . ')' );
}
if( count($_parents) AND $setID )
{
foreach( $_parents as $parent )
@@ -552,7 +727,7 @@ class skinFunctions
}
}
}
return TRUE;
}
@@ -576,13 +751,35 @@ class skinFunctions
*/
public function fetchReplacements( $setID )
{
$replacements = array();
//-----------------------------------------
// Try and get the skin from the cache
//-----------------------------------------
$skinSetData = $this->fetchSkinData( $setID );
$replacements = array();
/* Did we pass a master key? - all root skins are 0 */
if ( ! is_numeric( $setID ) )
{
$skinSetData = array( 'set_id' => 0,
'set_master_key' => $setID,
'set_key' => $setID,
'_isMaster' => 1,
'_parentTree' => array(),
'_childTree' => array(),
'_userAgents' => array(),
'_cssGroupsArray' => array() );
}
else
{
$skinSetData = $this->fetchSkinData( $setID );
}
/* Did we get a skin set? */
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
{
return array();
}
//-----------------------------------------
// Push root ID onto the END of the parent array
//-----------------------------------------
@@ -593,8 +790,29 @@ class skinFunctions
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_parentTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_parentTree'], $setID );
}
/* We want to capture only this set's master bits */
$where = ' AND ( ( replacement_set_id > 0 AND ( replacement_master_key=\'\' OR replacement_master_key IS NULL ) ) OR ( replacement_set_id=0 AND replacement_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
//-----------------------------------------
// Push root ID onto the END of the parent array
//-----------------------------------------
array_push( $skinSetData['_parentTree'], 0 );
//-----------------------------------------
// Push the current skin set ID onto the beginnging
//-----------------------------------------
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_parentTree'], $setID );
}
//-----------------------------------------
// Geddit
//-----------------------------------------
@@ -603,7 +821,7 @@ class skinFunctions
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'replacement_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
'from' => 'skin_replacements',
'where' => "replacement_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
'where' => "replacement_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
'order' => 'replacement_key ASC, theorder DESC' ) );
$i = $this->DB->execute();
@@ -809,7 +1027,7 @@ class skinFunctions
//-----------------------------------------
$replacementID = intval( $replacementID );
//-----------------------------------------
// Fetch replacement data
//-----------------------------------------
@@ -887,14 +1105,33 @@ class skinFunctions
*/
public function fetchCSS( $setID, $parse=TRUE, $skipRemoved=TRUE )
{
//-----------------------------------------
// Try and get the skin from the cache
//-----------------------------------------
$skinSetData = $this->fetchSkinData( $setID );
$css = array();
$skip = array();
$where = '';
/* Did we pass a master key? - all root skins are 0 */
if ( ! is_numeric( $setID ) )
{
$skinSetData = array( 'set_id' => 0,
'set_master_key' => $setID,
'set_key' => $setID,
'_isMaster' => 1,
'_parentTree' => array(),
'_childTree' => array(),
'_userAgents' => array(),
'_cssGroupsArray' => array() );
}
else
{
$skinSetData = $this->fetchSkinData( $setID );
}
/* Did we get a skin set? */
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
{
return array();
}
//-----------------------------------------
// Push root ID onto the END of the parent array
//-----------------------------------------
@@ -905,7 +1142,13 @@ class skinFunctions
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_parentTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_parentTree'], $setID );
}
/* We want to capture only this set's master bits */
$where = ' AND ( ( css_set_id > 0 AND ( css_master_key=\'\' OR css_master_key IS NULL ) ) OR ( css_set_id=0 AND css_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
//-----------------------------------------
// Geddit
@@ -915,7 +1158,7 @@ class skinFunctions
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'css_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
'from' => 'skin_css',
'where' => "css_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
'where' => "css_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
'order' => 'css_group, theorder DESC' ) );
$i = $this->DB->execute();
@@ -943,7 +1186,7 @@ class skinFunctions
$css[ $row['css_group'] ] = $row;
}
return $css;
}
@@ -992,6 +1235,7 @@ class skinFunctions
$css['_actualSetID'] = $css['css_set_id'];
$css['_belongsSetID'] = $setID;
$css['_isMaster'] = ( $css['css_master_key'] ) ? true : false;
//$css['_css_content'] = $css['css_content'];
//-----------------------------------------
@@ -1340,7 +1584,7 @@ class skinFunctions
* Fetch Templates from the tree
*
* @access public
* @param int Skin set ID
* @param mixed Skin key or Skin set ID
* @param string Type of data to return: 'allTemplates' will return the data [template_group][template_name], 'allNoContent' the same as 'allTemplates' minus the actual template content, 'groupNames'; [template_group] or groupTemplates, just that groups templates [template_name], groupTemplatesNoContent is the same as groupTemplates but template_content is removed
* @param string Which group to use
* @return array Array of data depending on the params
@@ -1352,6 +1596,8 @@ class skinFunctions
* $templates = $skinFunctions->fetchTemplates( 1, 'groupTemplates', 'skin_global' );
* # To return all templates in all groups
* $templates = $skinFunctions->fetchTemplates( 1, 'allTemplates');
* # To return all master templates for the mobile skin
* $templates = $skinFunctions->fetchTemplates( 'mobile', 'allTemplates' );
* </code>
*/
public function fetchTemplates( $setID, $type='allTemplates', $group='')
@@ -1361,13 +1607,31 @@ class skinFunctions
//-----------------------------------------
$templates = array();
$where = '';
/* Did we pass a master key? - all root skins are 0 */
if ( ! is_numeric( $setID ) )
{
$skinSetData = array( 'set_id' => 0,
'set_master_key' => $setID,
'set_key' => $setID,
'_isMaster' => 1,
'_parentTree' => array(),
'_childTree' => array(),
'_userAgents' => array(),
'_cssGroupsArray' => array() );
}
else
{
$skinSetData = $this->fetchSkinData( $setID );
}
/* Did we get a skin set? */
if ( ! isset( $skinSetData['_parentTree'] ) OR ! is_array( $skinSetData['_parentTree'] ) )
{
return array();
}
//-----------------------------------------
// Try and get the skin from the cache
//-----------------------------------------
$skinSetData = $this->fetchSkinData( $setID );
//-----------------------------------------
// Push root ID onto the END of the parent array
//-----------------------------------------
@@ -1377,9 +1641,63 @@ class skinFunctions
//-----------------------------------------
// Push the current skin set ID onto the beginnging
//-----------------------------------------
array_unshift( $skinSetData['_parentTree'], $setID );
if ( is_numeric( $setID ) )
{
array_unshift( $skinSetData['_parentTree'], $setID );
}
/* We want to capture only this set's master bits */
$where = ' AND ( ( template_set_id > 0 AND ( template_master_key=\'\' OR template_master_key IS NULL ) ) OR ( template_set_id=0 AND template_master_key=\'' . $skinSetData['set_master_key'] . '\' ) )';
/* First off, load 'root' skin as we tend to develop this the most and there is always a small chance other master skins won't
contain all the template bits. We'll just load the group / name and leave the content blank to prevent parse errors, etc */
if ( $setID != 'root' )
{
if ( ( $type == 'groupTemplates' OR $type == 'groupTemplatesNoContent' ) and $group != '' )
{
$_w = " AND template_group='{$group}'";
}
$this->DB->build( array( 'select' => '*',
'from' => 'skin_templates',
'where' => "template_master_key='root'" . $_w,
'order' => 'template_group' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$r['template_content'] = '<!--no data in this master skin-->';
if ( $type == 'groupNames' )
{
$templates[ $r['template_group'] ] = $r;
}
else if ( $type == 'groupTemplates' OR $type == 'groupTemplatesNoContent' )
{
$r['_templateSize'] = IPSLib::sizeFormat( IPSLib::strlenToBytes( strlen( $r['template_content'] ) ) );
if ( $type == 'groupTemplatesNoContent' )
{
unset( $r['template_data'] );
unset( $r['template_content'] );
}
$templates[ strtolower($r['template_name']) ] = $r;
}
else
{
if ( $type == 'allNoContent' )
{
unset( $r['template_content'] );
}
$templates[ $r['template_group'] ][ strtolower($r['template_name']) ] = $r;
}
}
}
//-----------------------------------------
// Ok, what to return?
//-----------------------------------------
@@ -1391,7 +1709,7 @@ class skinFunctions
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
'from' => 'skin_templates',
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) ." )",
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) ." )" . $where,
'order' => 'template_group, theorder DESC'
) );
$newq = $this->DB->execute();
@@ -1403,7 +1721,7 @@ class skinFunctions
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
'from' => 'skin_templates',
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) . ") AND template_group='{$group}'",
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) . ") AND template_group='{$group}'" . $where,
'order' => 'template_name, theorder DESC'
) );
$newq = $this->DB->execute();
@@ -1415,7 +1733,7 @@ class skinFunctions
$this->DB->buildInstring( "," . implode( ",", $skinSetData['_parentTree'] ) . ",",
$this->DB->buildConcat( array( array( ',', 'string' ), array( 'template_set_id' ), array( ',', 'string' ) ) ) ) . ' as theorder',
'from' => 'skin_templates',
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")",
'where' => "template_set_id IN (" . implode( ",", $skinSetData['_parentTree'] ) .")" . $where,
'order' => 'template_group, template_name, theorder DESC'
) );
$newq = $this->DB->execute();
@@ -1471,6 +1789,14 @@ class skinFunctions
}
ksort($templates);
foreach( $templates as $k => $v )
{
if( is_array($v) )
{
ksort($templates[ $k ]);
}
}
return $templates;
}
@@ -1500,8 +1826,8 @@ class skinFunctions
//-----------------------------------------
$template = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_id=' . $templateID ) );
'from' => 'skin_templates',
'where' => 'template_id=' . $templateID ) );
if ( ! $template['template_id'] )
{
@@ -1522,6 +1848,7 @@ class skinFunctions
$template['_belongsSetID'] = $setID;
$template['_template_content'] = $template['template_content'];
$template['_template_data'] = $template['template_data'];
$template['_isMaster'] = ( $template['template_master_key'] ) ? true : false;
//-----------------------------------------
// Update content for editing
@@ -1712,7 +2039,7 @@ class skinFunctions
// Test it..
//-----------------------------------------
if ( $this->testTemplateBitSyntax( $template['template_name'], $template_data, $template_content ) !== TRUE )
if ( $this->testTemplateBitSyntax( $template_name, $template_data, $template_content ) !== TRUE )
{
throw new Exception( "SYNTAX_INCORRECT" );
}
@@ -2034,9 +2361,10 @@ class skinFunctions
{
continue;
}
$config = array();
require( $path . '/' . $_name . '/conf.php' );
$formats[ $_name ] = $config;
}
}
@@ -2060,7 +2388,7 @@ class skinFunctions
/* Fetch groups? */
if ( ! count( $groups ) )
{
$groups = array_keys( $this->fetchTemplates( 1, 'groupNames' ) );
$groups = array_keys( $this->fetchTemplates( 'root', 'groupNames' ) );
}
/* Got a hooks cache? */
@@ -2074,21 +2402,21 @@ class skinFunctions
if( is_array( $hooksCache['templateHooks'] ) AND count( $hooksCache['templateHooks'] ) )
{
foreach( $hooksCache['templateHooks'] as $hook )
foreach( $hooksCache['templateHooks'] as $skinGroup => $hooks )
{
foreach( $hook as $tplHook )
/* Check to see if the group is loaded */
if( ! in_array( $skinGroup, $groups ) )
{
/* Check to see if the group is loaded */
if( ! in_array( $tplHook['skinGroup'], $groups ) )
{
continue;
}
continue;
}
foreach( $hooks as $tplHook )
{
/* Check for hook file */
if( file_exists( DOC_IPS_ROOT_PATH . 'hooks/' . $tplHook['filename'] ) )
{
$tplHook['_commentTag'] = $tplHook['type'] . '.' . $tplHook['skinGroup'] . '.' . $tplHook['skinFunction'] . '.' . $tplHook['id'] . '.' . $tplHook['position'];
$myHooks[ $tplHook['skinGroup'] ][] = $tplHook;
$tplHook['_commentTag'] = $tplHook['type'] . '.' . $skinGroup . '.' . $tplHook['skinFunction'] . '.' . $tplHook['id'] . '.' . $tplHook['position'];
$myHooks[ $skinGroup ][] = $tplHook;
}
}
}
@@ -2123,9 +2451,10 @@ class skinFunctions
*
* @access public
* @param int Skin set ID
* @param bool Force load from DB
* @return array
*/
public function fetchSkinData( $setID )
public function fetchSkinData( $setID, $forceLoadDB=false )
{
//-----------------------------------------
// Skin ID #0?
@@ -2135,7 +2464,8 @@ class skinFunctions
{
/* This is a master skin, so lets fake it */
$skinSetData['set_id'] = 0;
$skinSetData['set_key'] = 'root';
$skinSetData['set_key'] = is_numeric( $setID ) ? 'root' : $setID;
$skinSetData['set_master_key'] = is_numeric( $setID ) ? 'root' : $setID;
$skinSetData['_isMaster'] = 1;
$skinSetData['_parentTree'] = array();
$skinSetData['_childTree'] = array();
@@ -2174,7 +2504,7 @@ class skinFunctions
// Got nothing?
//-----------------------------------------
if ( $setID > 0 AND ! is_array( $skinSetData ) )
if ( $forceLoadDB OR ( $setID > 0 AND ! $skinSetData['set_id'] ) )
{
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_collections',
@@ -2199,6 +2529,9 @@ class skinFunctions
$skinSetData['_cssGroupsArray'] = array();
}
}
/* Fail safe */
$skinSetData['set_master_key'] = ( $skinSetData['set_master_key'] ) ? $skinSetData['set_master_key'] : 'root';
return $skinSetData;
}
@@ -2306,8 +2639,10 @@ class skinFunctions
// Test...
//-----------------------------------------
$eval = $this->registry->templateEngine->convertHtmlToPhp( 'test__' . $name, $data, $content );
ob_start();
eval( $this->registry->templateEngine->convertHtmlToPhp( 'test__' . $name, $data, $content ) );
eval( $eval );
$return = ob_get_contents();
ob_end_clean();
@@ -2418,7 +2753,7 @@ class skinFunctions
$templates = $this->fetchTemplates( 0, 'groupTemplatesNoContent', $_group );
/* Clean out any template bits no longer part of this group */
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND LOWER(template_name) NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
$this->DB->delete( 'skin_templates', "template_group='" . $_group . "' AND " . $this->DB->buildLower('template_name') . " NOT IN ('" . implode( "','", array_keys( $templates ) ) . "')" );
$affected += intval( $this->DB->getAffectedRows() );
}
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Skin Functions
* Last Updated: $Date: 2009-09-28 18:04:38 -0400 (Mon, 28 Sep 2009) $
* Last Updated: $Date: 2010-09-13 05:53:37 -0400 (Mon, 13 Sep 2010) $
* </pre>
*
* Owner: Matt
* @author $Author: josh $
* @author $Author: terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5170 $
* @version $Revision: 6854 $
*
*/
@@ -68,13 +70,23 @@ class skinImportExport extends skinCaching
//-----------------------------------------
$addedCount = 0;
$masterKeys = $this->fetchMasterKeys();
$skinMasterKey = '';
//-----------------------------------------
// Got anything?
//-----------------------------------------
$replacements = $this->parseReplacementsXML( $content );
$where = ( is_numeric( $setID ) ) ? 'replacement_set_id=' . $setID : 'replacement_master_key=\'' . $setID . '\'';
/* If this is a 'master' skin, then reset master key */
if ( in_array( $setID, $masterKeys ) )
{
$skinMasterKey = $setID;
$setID = 0;
}
//-----------------------------------------
// Replacements...
//-----------------------------------------
@@ -82,7 +94,7 @@ class skinImportExport extends skinCaching
if ( is_array( $replacements ) )
{
/* Get all the keys for this set id */
$this->DB->build( array( 'select' => 'replacement_key', 'from' => 'skin_replacements', 'where' => "replacement_set_id={$setID}" ) );
$this->DB->build( array( 'select' => 'replacement_key', 'from' => 'skin_replacements', 'where' => $where ) );
$this->DB->execute();
$repKeyCache = array();
@@ -100,21 +112,16 @@ class skinImportExport extends skinCaching
if( in_array( $replacement['replacement_key'], $repKeyCache ) )
{
$this->DB->update( 'skin_replacements', array(
'replacement_content' => $replacement['replacement_content']
),
"replacement_key='{$replacement['replacement_key']}' AND replacement_set_id={$setID}"
);
$this->DB->update( 'skin_replacements', array( 'replacement_content' => $replacement['replacement_content'] ), "replacement_key='{$replacement['replacement_key']}' AND " . $where );
}
else
{
$this->DB->insert( 'skin_replacements', array(
'replacement_key' => $replacement['replacement_key'],
'replacement_content' => $replacement['replacement_content'],
'replacement_set_id' => $setID,
'replacement_added_to' => $setID
)
);
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
'replacement_content' => $replacement['replacement_content'],
'replacement_set_id' => $setID,
'replacement_added_to' => $setID,
'replacement_master_key' => $skinMasterKey
) );
}
}
}
@@ -149,7 +156,7 @@ class skinImportExport extends skinCaching
if ( ! strstr( $content, "<xmlarchive" ) )
{
$this->_addErrorMessage( "Содержимое не является XMLArchive" );
$this->_addErrorMessage( $this->lang->words['invalidxmlarchivei'] );
return FALSE;
}
@@ -164,7 +171,7 @@ class skinImportExport extends skinCaching
if ( ! $xmlArchive->countFileArray() )
{
$this->_addErrorMessage( "XMLArchive пуст" );
$this->_addErrorMessage( $this->lang->words['emptyxmlarchivei'] );
return FALSE;
}
@@ -177,13 +184,13 @@ class skinImportExport extends skinCaching
if ( $this->checkImageDirectoryExists( $imageSetName ) === TRUE )
{
/* Already exists... */
$this->_addErrorMessage( "Директория public/style_images/{$imageSetName} уже существует" );
$this->_addErrorMessage( sprintf( $this->lang->words['imagediralreadyexists'], $imageSetName ) );
return FALSE;
}
if ( $this->createNewImageDirectory( $imageSetName ) !== TRUE )
{
$this->_addErrorMessage( "Не удалось создать public/style_images/{$imageSetName}. Проверьте права доступа и повторите попытку снова." );
$this->_addErrorMessage( sprintf( $this->lang->words['imagedircannotcreate'], $imageSetName ) );
return FALSE;
}
@@ -201,7 +208,7 @@ class skinImportExport extends skinCaching
/* Write it */
if ( $xmlArchive->write( $content, $this->fetchImageDirectoryPath( $imageSetName ) ) === FALSE )
{
$this->_addErrorMessage( "Не удалось записать файлы изображений" );
$this->_addErrorMessage( $this->lang->words['cannotwriteimageset'] );
return FALSE;
}
@@ -245,21 +252,23 @@ class skinImportExport extends skinCaching
* @param int [ Skin set parent. If omitted, it will be made a root skin ]
* @param string [ Images directory to use. If omitted, default skin's image dir is used ]
* @param string [ Name of skin to create. If omitted, name from skin set is used ]
* @param bool [ Whether or not we are attempting to upgrade an existing skin ]
* @return mixed bool, or number of items added
*/
public function importSetXMLArchive( $content, $parentID=0, $imageDir='', $setName='' )
public function importSetXMLArchive( $content, $parentID=0, $imageDir='', $setName='', $upgrading=FALSE )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$templates = array();
$csss = array();
$groups = array();
$defaultSkin = array();
$return = array( 'replacements' => 0,
'css' => 0,
'templates' => 0 );
$templates = array();
$csss = array();
$groups = array();
$defaultSkin = array();
$return = array( 'replacements' => 0,
'css' => 0,
'templates' => 0,
'upgrade' => FALSE );
//-----------------------------------------
// Got anything?
@@ -267,7 +276,7 @@ class skinImportExport extends skinCaching
if ( ! strstr( $content, "<xmlarchive" ) )
{
$this->_addErrorMessage( "Содержимое не является XMLArchive" );
$this->_addErrorMessage( $this->lang->words['invalidxmlarchivei'] );
return FALSE;
}
@@ -294,7 +303,7 @@ class skinImportExport extends skinCaching
if ( ! $xmlArchive->countFileArray() )
{
$this->_addErrorMessage( "XMLArchive пуст" );
$this->_addErrorMessage( $this->lang->words['emptyxmlarchivei'] );
return FALSE;
}
@@ -307,12 +316,34 @@ class skinImportExport extends skinCaching
if( !$infoXml )
{
$this->_addErrorMessage( "Файл info.xml пуст или отсутствует" );
$this->_addErrorMessage( $this->lang->words['noinfoxml'] );
return FALSE;
}
$info = $this->parseInfoXML( $infoXml );
/* Are we attempting to upgrade? */
$setID = 0;
$doUpgrade = FALSE;
$new_items = array( 'replacements' => array(),
'css' => array(),
'templates' => array(),
);
if ( $info['set_key'] && $upgrading )
{
foreach ( $this->caches['skinsets'] as $set_id => $set_data )
{
if ( $set_data['set_key'] == $info['set_key'] )
{
$setID = $set_id;
$doUpgrade = TRUE;
$return['upgrade'] = TRUE;
break;
}
}
}
/* Replacements */
$replacements = $this->parseReplacementsXML( $xmlArchive->getFile( 'replacements.xml' ) );
@@ -336,7 +367,7 @@ class skinImportExport extends skinCaching
if ( ! is_array( $info ) )
{
$this->_addErrorMessage( "XMLArchive не содержит файл info.xml" );
$this->_addErrorMessage( $this->lang->words['noinfoxml'] );
return FALSE;
}
@@ -355,12 +386,22 @@ class skinImportExport extends skinCaching
}
}
/* Make sure key in unique */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_collections',
'where' => 'set_key=\'' . $this->DB->addSlashes( $info['set_key'] ) . '\' AND set_id != ' . intval( $setID ) ) );
if ( $test['set_id'] )
{
$info['set_key'] .= '_' . time();
}
//-----------------------------------------
// Build Set Array
//-----------------------------------------
$newSet = array('set_name' => ( $setName ) ? $setName : $info['set_name'] . ' (Import)',
'set_key' => '',
'set_key' => $info['set_key'],
'set_parent_id' => $parentID,
'set_permissions' => implode( ",", $groups ),
'set_is_default' => 0,
@@ -372,15 +413,31 @@ class skinImportExport extends skinCaching
'set_output_format' => $info['set_output_format'],
'set_css_groups' => '',
'set_hide_from_list' => 1, // Per Rikki :P
'set_order' => intval( $this->fetchHighestSetPosition() ) + 1,
'set_master_key' => ( isset( $info['set_master_key'] ) ) ? $info['set_master_key'] : 'root',
'set_updated' => time() );
//-----------------------------------------
// Insert...
//-----------------------------------------
$this->DB->insert( 'skin_collections', $newSet );
$setID = $this->DB->getInsertId();
if ( $setID )
{
//-----------------------------------------
// Update...
//-----------------------------------------
$this->DB->update( 'skin_collections', array( 'set_author_name' => $info['set_author_name'],
'set_author_url' => $info['set_author_url'],
'set_updated' => time(),
), 'set_id=' . $setID );
}
else
{
//-----------------------------------------
// Insert...
//-----------------------------------------
$this->DB->insert( 'skin_collections', $newSet );
$setID = $this->DB->getInsertId();
}
/* Rebuild trees */
$this->rebuildTreeInformation( $setID );
@@ -409,11 +466,31 @@ class skinImportExport extends skinCaching
if ( $replacement['replacement_key'] )
{
$return['replacements']++;
$existing_id = 0;
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
'replacement_content' => $replacement['replacement_content'],
'replacement_set_id' => $setID,
'replacement_added_to' => $setID ) );
/* Check if we need to update or insert */
if ( $doUpgrade )
{
$exists = $this->DB->buildAndFetch( array( 'select' => 'replacement_id',
'from' => 'skin_replacements',
'where' => "replacement_key='{$replacement['replacement_key']}' AND replacement_set_id={$setID} AND replacement_added_to={$setID}" ) );
$existing_id = $exists['replacement_id'];
}
if ( $existing_id )
{
$new_items['replacements'][] = $existing_id;
$this->DB->update( 'skin_replacements', array( 'replacement_content' => $replacement['replacement_content'] ), "replacement_id=".$existing_id );
}
else
{
$this->DB->insert( 'skin_replacements', array( 'replacement_key' => $replacement['replacement_key'],
'replacement_content' => $replacement['replacement_content'],
'replacement_set_id' => $setID,
'replacement_added_to' => $setID ) );
}
}
}
}
@@ -436,17 +513,42 @@ class skinImportExport extends skinCaching
if ( $css['css_group'] )
{
$return['css']++;
$this->DB->insert( 'skin_css', array( 'css_group' => $css['css_group'],
'css_content' => $css['css_content'],
'css_position' => $css['css_position'],
'css_attributes' => $css['css_attributes'],
'css_app' => $css['css_app'],
'css_app_hide' => $css['css_app_hide'],
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
'css_updated' => time(),
'css_set_id' => $setID,
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ) );
$existing_id = 0;
/* Check if we need to update or insert */
if ( $doUpgrade )
{
$exists = $this->DB->buildAndFetch( array( 'select' => 'css_id',
'from' => 'skin_css',
'where' => "css_group='{$css['css_group']}' AND css_app='{$css['css_app']}' AND css_set_id={$setID}" ) );
$existing_id = $exists['css_id'];
}
if ( $existing_id )
{
$new_items['css'][] = $existing_id;
$this->DB->update( 'skin_css', array( 'css_content' => $css['css_content'],
'css_position' => $css['css_position'],
'css_attributes' => $css['css_attributes'],
'css_app_hide' => $css['css_app_hide'],
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
'css_updated' => time(),
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ), "css_id=".$existing_id );
}
else
{
$this->DB->insert( 'skin_css', array( 'css_group' => $css['css_group'],
'css_content' => $css['css_content'],
'css_position' => $css['css_position'],
'css_attributes' => $css['css_attributes'],
'css_app' => $css['css_app'],
'css_app_hide' => $css['css_app_hide'],
'css_modules' => str_replace( ' ', '', $css['css_modules'] ),
'css_updated' => time(),
'css_set_id' => $setID,
'css_added_to' => ( isset( $_MASTER[ $css['css_group'] ] ) ) ? 0 : $setID ) );
}
}
}
}
@@ -474,23 +576,70 @@ class skinImportExport extends skinCaching
$isAdded = ( is_array( $_MASTER[ $template['template_group'] ][ strtolower( $template['template_name'] ) ] ) AND ! $_MASTER[ $template['template_group'] ][ strtolower( $template['template_name'] ) ]['template_user_added'] ) ? 0 : 1;
$return['templates']++;
$this->DB->insert( 'skin_templates', array( 'template_set_id' => $setID,
'template_group' => $template['template_group'],
'template_content' => $template['template_content'],
'template_name' => $template['template_name'],
'template_data' => $template['template_data'],
'template_updated' => $template['template_updated'],
'template_removable' => 1,
'template_user_edited' => 1,
'template_user_added' => $isAdded,
'template_added_to' => $setID ) );
$existing_id = 0;
/* Check if we need to update or insert */
if ( $doUpgrade )
{
$exists = $this->DB->buildAndFetch( array( 'select' => 'template_id',
'from' => 'skin_templates',
'where' => "template_set_id={$setID} AND template_group='{$template['template_group']}' AND template_name='{$template['template_name']}'" ) );
$existing_id = $exists['template_id'];
}
if ( $existing_id )
{
$new_items['templates'][] = $existing_id;
$this->DB->update( 'skin_templates', array( 'template_content' => $template['template_content'],
'template_data' => $template['template_data'],
'template_updated' => $template['template_updated'],
'template_removable' => 1,
'template_user_edited' => 1,
'template_user_added' => $isAdded,
'template_added_to' => $setID ), "template_id=".$existing_id );
}
else
{
$this->DB->insert( 'skin_templates', array( 'template_set_id' => $setID,
'template_group' => $template['template_group'],
'template_content' => $template['template_content'],
'template_name' => $template['template_name'],
'template_data' => $template['template_data'],
'template_updated' => $template['template_updated'],
'template_removable' => 1,
'template_user_edited' => 1,
'template_user_added' => $isAdded,
'template_added_to' => $setID ) );
}
}
}
}
}
}
//-----------------------------------------
// If upgrading, and there are items from an old
// skin not in the new one, delete the old elements
// This probably won't ever come up, but I'm anal retentive :P
//-----------------------------------------
if ( $doUpgrade )
{
if ( count( $new_items['replacements'] ) )
{
$this->DB->delete( 'skin_replacements', "replacement_set_id={$setID} AND replacement_id NOT IN (" . implode( ',', $new_items['replacements']) . ")" );
}
if ( count( $new_items['css'] ) )
{
$this->DB->delete( 'skin_css', "css_set_id={$setID} AND css_id NOT IN (" . implode( ',', $new_items['css']) . ")" );
}
if ( count( $new_items['templates'] ) )
{
$this->DB->delete( 'skin_templates', "template_set_id={$setID} AND template_id NOT IN (" . implode( ',', $new_items['templates']) . ")" );
}
}
//-----------------------------------------
// Re-cache
//-----------------------------------------
@@ -677,7 +826,7 @@ class skinImportExport extends skinCaching
if ( $this->checkImageDirectoryExists( $imgDir ) !== TRUE )
{
$this->_addErrorMessage( "Директории изображений $imgDir не существует" );
$this->_addErrorMessage( sprintf( $this->lang->words['imagedirnotexists'], $imgDir ) );
return FALSE;
}
@@ -757,16 +906,16 @@ class skinImportExport extends skinCaching
foreach( $templates as $app_dir => $templateXML )
{
IPSDebug::addLogMessage( "Template Export: $app_dir\n".$templateXML, 'admin-setExport' );
IPSDebug::addLogMessage( "Template Export: $app_dir\n".$templateXML, 'admin-setExport', false, true, true );
}
foreach( $csss as $app_dir => $cssXML )
{
IPSDebug::addLogMessage( "CSS Export: $app_dir\n".$cssXML, 'admin-setExport' );
IPSDebug::addLogMessage( "CSS Export: $app_dir\n".$cssXML, 'admin-setExport', false, true );
}
IPSDebug::addLogMessage( "Replacements Export:\n".$replacements, 'admin-setExport' );
IPSDebug::addLogMessage( "Info Export:\n".$info, 'admin-setExport' );
IPSDebug::addLogMessage( "Replacements Export:\n".$replacements, 'admin-setExport', false, true );
IPSDebug::addLogMessage( "Info Export:\n".$info, 'admin-setExport', false, true );
//-----------------------------------------
// Create new XML archive...
@@ -775,6 +924,10 @@ class skinImportExport extends skinCaching
require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );
$xmlArchive = new classXMLArchive();
/* Add in version numbers */
$version = IPSLib::fetchVersionNumber();
$xmlArchive->addRootTagValues( array( 'ipbLongVersion' => $version['long'], 'ipbHumanVersion' => $version['human'] ) );
# Templates
foreach( $templates as $app_dir => $templateXML )
{
@@ -813,18 +966,30 @@ class skinImportExport extends skinCaching
$this->_resetErrorHandle();
$this->_resetMessageHandle();
if ( $setID == 0 )
{
/* This is which skins we want to export for default installations */
$skinIDs = array_values( $this->remapData['export'] );
}
else
{
$skinIDs = array( $setID );
}
foreach( $skinIDs as $setID )
{
foreach( ipsRegistry::$applications as $app_dir => $app_data )
{
if ( ! file_exists( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
{
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не существует" );
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirmissing'] );
continue;
}
else if ( ! is_writable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
{
if ( ! @chmod( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) )
{
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не имеет прав на запись" );
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirnotwrite'] );
continue;
}
}
@@ -832,6 +997,7 @@ class skinImportExport extends skinCaching
$this->exportTemplateAppXML( $app_dir, $setID, $setOnly );
}
}
}
/**
* Export all Apps CSS
@@ -849,20 +1015,32 @@ class skinImportExport extends skinCaching
$this->_resetErrorHandle();
$this->_resetMessageHandle();
if ( $setID == 0 )
{
/* This is which skins we want to export for default installations */
$skinIDs = array_values( $this->remapData['export'] );
}
else
{
$skinIDs = array( $setID );
}
foreach( $skinIDs as $setID )
{
foreach( ipsRegistry::$applications as $app_dir => $app_data )
{
$file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_css.xml';
if ( ! file_exists( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
{
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не существует" );
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirmissing'] );
continue;
}
else if ( ! is_writable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
{
if ( ! @chmod( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) )
{
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . "/xml/ не имеет прав на запись" );
$this->_addErrorMessage( IPSLib::getAppDir( $app_dir ) . $this->lang->words['xmldirnotwrite'] );
continue;
}
}
@@ -870,6 +1048,7 @@ class skinImportExport extends skinCaching
$this->exportCSSAppXML( $app_dir, $setID );
}
}
}
/**
* Import all Apps skin files
@@ -893,13 +1072,13 @@ class skinImportExport extends skinCaching
if ( ! file_exists( $file ) )
{
$this->_addMessage( $app_dir . ': нечего импортировать' );
$this->_addMessage( $app_dir . $this->lang->words['importnothingtoimport'] );
continue;
}
else
{
$return = $this->importTemplateAppXML( $app_dir, 0 );
$this->_addMessage( $app_dir . ': ' . $return['updateCount'] . ' добавлено, ' . $return['insertCount'] . ' обновлено' );
$this->_addMessage( sprintf( $this->lang->words['importaddupdate'], $app_dir, $return['updateCount'], $return['insertCount'] ) );
}
}
}
@@ -917,11 +1096,25 @@ class skinImportExport extends skinCaching
// INIT
//-----------------------------------------
$skins = array();
$setid = 1;
$skins = array();
$setid = 1;
$exports = array_values( $this->remapData['export'] );
$remap = array( 'mobile' => array( 'set_id' => 2,
'set_name' => 'IP.Board Mobile',
'set_key' => 'mobile',
'set_master_key' => 'mobile',
'set_output_format' => 'html',
'set_image_dir' => 'mobile',
'set_locked_uagent' => 'a:2:{s:6:"groups";a:0:{}s:7:"uagents";a:10:{s:10:"blackberry";s:0:"";s:6:"iphone";s:0:"";s:9:"ipodtouch";s:0:"";s:12:"sonyericsson";s:0:"";s:5:"nokia";s:0:"";s:8:"motorola";s:0:"";s:7:"samsung";s:0:"";s:3:"htc";s:0:"";s:2:"lg";s:0:"";s:4:"palm";s:0:"";}}' ),
'xmlskin' => array( 'set_id' => 3,
'set_name' => 'IP.Board XML',
'set_key' => 'xmlskin',
'set_master_key' => 'xmlskin',
'set_output_format' => 'xml',
'set_image_dir' => 'master' ) );
/* Figure out ID 0 */
if ( in_array( 0, $skinIDs ) )
if ( in_array( 0, $skinIDs ) OR in_array( 'root', $skinIDs ) )
{
$cssSkinCollections = array();
$_css = $this->fetchCSS( 0 );
@@ -943,7 +1136,7 @@ class skinImportExport extends skinCaching
'set_permissions' => '*',
'set_is_default' => 1,
'set_author_name' => 'Invision Power Services, Inc',
'set_author_url' => '',
'set_author_url' => 'http://www.bestcms.ws',
'set_image_dir' => 'master',
'set_emo_dir' => 'default',
'set_css_inline' => 1,
@@ -952,27 +1145,70 @@ class skinImportExport extends skinCaching
'set_updated' => time(),
'set_output_format' => 'html',
'set_locked_uagent' => '',
'set_hide_from_list' => 0 );
'set_hide_from_list' => 0,
'set_master_key' => 'root' );
}
/* Grab the rest */
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'where' => 'set_id IN (' . implode( ",", $skinIDs ) . ')' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
foreach( $exports as $_id )
{
/* Ensure settings */
$row['set_id'] = $setid;
$row['set_permissions'] = '*';
$row['set_hide_from_list'] = 0;
$row['set_css_inline'] = 1;
if ( $_id != 'root' AND in_array( $_id, $skinIDs ) )
{
$cssSkinCollections = array();
$_css = $this->fetchCSS( $_id );
foreach( $_css as $name => $css )
{
/* Build skin set row*/
$cssSkinCollections[ $css['css_position'] . '.' . $css['css_id'] ] = array( 'css_group' => $css['css_group'], 'css_position' => $css['css_position'] );
}
$setid++;
$skins[ $remap[ $_id ]['set_id'] ] = array( 'set_id' => $remap[ $_id ]['set_id'],
'set_name' => $remap[ $_id ]['set_name'],
'set_key' => $remap[ $_id ]['set_key'],
'set_parent_id' => 0,
'set_parent_array' => serialize( array() ),
'set_child_array' => serialize( array() ),
'set_permissions' => '*',
'set_is_default' => 1,
'set_author_name' => 'Invision Power Services, Inc',
'set_author_url' => 'http://www.bestcms.ws',
'set_image_dir' => $remap[ $_id ]['set_image_dir'],
'set_emo_dir' => 'default',
'set_css_inline' => 1,
'set_css_groups' => serialize( $cssSkinCollections ),
'set_added' => time(),
'set_updated' => time(),
'set_output_format' => $remap[ $_id ]['set_output_format'],
'set_locked_uagent' => ( isset( $remap[ $_id ]['set_locked_uagent'] ) ) ? $remap[ $_id ]['set_locked_uagent'] : '',
'set_hide_from_list' => 0,
'set_master_key' => $remap[ $_id ]['set_master_key'] );
}
}
if ( count( $skins ) != count( $skinIDs ) )
{
/* Grab the rest */
$this->DB->build( array( 'select' => '*',
'from' => 'skin_collections',
'where' => 'set_id IN (' . implode( ",", $skinIDs ) . ')' ) );
$this->DB->execute();
$skins[ $row['set_id'] ] = $row;
$setid++;
while( $row = $this->DB->fetch() )
{
/* Ensure settings */
$row['set_id'] = $setid;
$row['set_permissions'] = '*';
$row['set_hide_from_list'] = 0;
$row['set_css_inline'] = 1;
$skins[ $row['set_id'] ] = $row;
$setid++;
}
}
//-----------------------------------------
@@ -1019,9 +1255,11 @@ class skinImportExport extends skinCaching
if ( $setOnly === TRUE )
{
$where = ( is_numeric( $setID ) ) ? 'replacement_set_id=' . $setID : 'replacement_master_key=\'' . $setID . '\'';
$this->DB->build( array( 'select' => '*',
'from' => 'skin_replacements',
'where' => 'replacement_set_id=' . $setID ) );
'where' => $where ) );
$this->DB->execute();
@@ -1037,7 +1275,7 @@ class skinImportExport extends skinCaching
if ( ! is_array( $replacements ) OR ! count( $replacements ) )
{
$this->_addMessage( "Нет макросов для экспортирования" );
$this->_addMessage( $this->lang->words['noreplacementstoexport'] );
return FALSE;
}
@@ -1128,7 +1366,7 @@ class skinImportExport extends skinCaching
if ( ! is_array( $css ) OR ! count( $css ) )
{
$this->_addMessage( "Нет CSS для экспортирования в " . $app_dir );
$this->_addMessage( $this->lang->words['nocsstoexport'] . $app_dir );
return FALSE;
}
@@ -1168,7 +1406,7 @@ class skinImportExport extends skinCaching
if ( ! $gotSomething )
{
$this->_addMessage( "Нет CSS для экспортирования в " . $app_dir );
$this->_addMessage( $this->lang->words['nocsstoexport'] . $app_dir );
return FALSE;
}
@@ -1200,7 +1438,7 @@ class skinImportExport extends skinCaching
if ( ! file_exists( $infoXML ) )
{
$this->_addErrorMessage( "Не удалось найти: " . $infoXML );
$this->_addErrorMessage( $this->lang->words['couldnotlocate'] . $infoXML );
return FALSE;
}
@@ -1226,13 +1464,14 @@ class skinImportExport extends skinCaching
if ( ! is_array( $templateGroups ) OR ! count( $templateGroups ) )
{
$this->_addMessage( "Нечего экспортировать для приложения " . $app . ": Не установлены группы в information.xml" );
$this->_addMessage( sprintf( $this->lang->words['nothingtoexportforapp'], $app ) );
return FALSE;
}
//-----------------------------------------
// Fetch templates
//-----------------------------------------
$templates = array();
if ( $setOnly === TRUE AND $setID > 0 )
{
@@ -1283,7 +1522,7 @@ class skinImportExport extends skinCaching
if ( ! is_array( $templates ) OR ! count( $templates ) )
{
$this->_addMessage( "Нечего экспортировать для приложения " . $app . ": Нет шаблонов" );
$this->_addMessage( sprintf( $this->lang->words['nogroupsforexportapp'], $app ) );
return FALSE;
}
@@ -1308,9 +1547,21 @@ class skinImportExport extends skinCaching
$_okToGo = TRUE;
}
}
/* If this is the core app, allow any custom bits also */
if ( $app == 'core' )
{
$_data = $data;
$test = array_shift( $_data );
if ( $test['template_user_added'] )
{
$_okToGo = TRUE;
}
}
if ( $_okToGo === TRUE )
{
{
$xml->addElement( 'templategroup', 'templates', array( 'group' => $group ) );
foreach( $data as $name => $templateData )
@@ -1328,7 +1579,7 @@ class skinImportExport extends skinCaching
if ( ! $added )
{
$this->_addMessage( "Нечего экспортировать для " . $app );
$this->_addMessage( $this->lang->words['nothingtoexportfor'] . $app );
return FALSE;
}
@@ -1350,7 +1601,8 @@ class skinImportExport extends skinCaching
$data = array();
$setData = $this->fetchSkinData( $setID );
$version = IPSLib::fetchVersionNumber();
//-----------------------------------------
// Grab the XML parser
//-----------------------------------------
@@ -1366,9 +1618,13 @@ class skinImportExport extends skinCaching
$xml->addElement( 'info' );
$xml->addElementAsRecord( 'info', 'data', array( 'set_name' => $setData['set_name'],
'set_key' => $setData['set_key'],
'set_author_name' => $setData['set_author_name'],
'set_author_url' => $setData['set_author_url'],
'set_output_format' => $setData['set_output_format'],
'set_master_key' => $setData['set_master_key'],
'ipb_human_version' => $version['human'],
'ipb_long_version' => $version['long'],
'ipb_major_version' => '3' ) );
return $xml->fetchDocument();
@@ -1391,6 +1647,7 @@ class skinImportExport extends skinCaching
$fileXML = IPSLib::getAppDir( $app ) . '/xml/' . $app . '_' . $skinKey . '_css.xml';
$return = array( 'updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array() );
$masterKeys = $this->fetchMasterKeys();
//-----------------------------------------
// File exists
@@ -1401,23 +1658,31 @@ class skinImportExport extends skinCaching
return FALSE;
}
if ( ! $setID and $skinKey != 'root' )
if ( ! $setID and ! in_array( $skinKey, $masterKeys ) )
{
/* Figure out correct set ID based on key */
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_collections',
'where' => "set_key='" . $skinKey . "'" ) );
$setID = $skinSetData['set_id'];
$setID = $skinSetData['set_id'];
$skinMasterKey = $skinSetData['set_master_key'];
}
/* If this is a 'master' skin, then reset master key */
if ( in_array( $skinKey, $masterKeys ) )
{
$skinMasterKey = $skinKey;
$setID = 0;
}
//-----------------------------------------
// Delete all CSS if this is set ID 0
//-----------------------------------------
if ( ! $setID )
if ( in_array( $skinKey, $masterKeys ) )
{
$this->DB->delete( 'skin_css', 'css_set_id=0 AND css_app=\''. addslashes( $app ) . '\'' );
$this->DB->delete( 'skin_css', 'css_set_id=0 AND css_master_key=\'' . $skinMasterKey . '\' AND css_app=\''. addslashes( $app ) . '\'' );
}
//-----------------------------------------
@@ -1447,6 +1712,7 @@ class skinImportExport extends skinCaching
'css_app_hide' => $_css['css_app_hide'],
'css_attributes' => $_css['css_attributes'],
'css_modules' => $_css['css_modules'],
'css_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
'css_set_id' => $setID,
'css_added_to' => $setID ) );
}
@@ -1487,17 +1753,13 @@ class skinImportExport extends skinCaching
{
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
{
$this->_addErrorMessage( $file . ' нет прав на запись' );
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
return FALSE;
}
file_put_contents( $file, $xml );
$this->_addMessage( "CSS для " . $app_dir . ' - ' . $setData['set_key'] . " создан" );
}
else
{
//$this->_addMessage( "CSS XML for " . $app_dir . ' - ' . $setData['set_key'] . " could not be generated" );
$this->_addMessage( sprintf( $this->lang->words['csscreatedmsg'], $app_dir, $setData['set_key'] ) );
}
}
@@ -1533,17 +1795,13 @@ class skinImportExport extends skinCaching
{
if ( file_exists( $file ) AND ! IPSLib::isWritable( $file ) )
{
$this->_addErrorMessage( $file . ' нет прав на запись' );
$this->_addErrorMessage( $file . $this->lang->words['css_isnotwritable'] );
return FALSE;
}
file_put_contents( $file, $xml );
$this->_addMessage( "Шаблоны для " . $app_dir . ' - ' . $setData['set_key'] . " созданы" );
}
else
{
//$this->_addMessage( "XML for " . $app_dir . ' - ' . $setData['set_key'] . " could not be generated" );
$this->_addMessage( sprintf( $this->lang->words['templatescreatedmsg'], $app_dir, $setData['set_key'] ) );
}
}
@@ -1568,28 +1826,37 @@ class skinImportExport extends skinCaching
$fileXML = IPSLib::getAppDir( $app ) . '/xml/' . $app . '_' . $skinKey . '_templates.xml';
$infoXML = IPSLib::getAppDir( $app ) . '/xml/information.xml';
$return = array( 'updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array() );
$masterKeys = $this->fetchMasterKeys();
if( ! file_exists($fileXML) )
{
return $return;
}
if ( ! $setID and $skinKey != 'root' )
if ( ! $setID and ! in_array( $skinKey, $masterKeys ) )
{
/* Figure out correct set ID based on key */
$skinSetData = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'skin_collections',
'where' => "set_key='" . $skinKey . "'" ) );
$setID = $skinSetData['set_id'];
$setID = $skinSetData['set_id'];
$skinMasterKey = $skinSetData['set_master_key'];
}
/* Set ignore flag correctly */
if ( ! empty( $skinKey ) AND in_array( $skinKey, array( 'root', 'lofi', 'xmlskin' ) ) )
if ( ! empty( $skinKey ) AND in_array( $skinKey, $masterKeys ) )
{
$ignoreAddedEditedFlag = true;
}
/* If this is a 'master' skin, then reset master key */
if ( in_array( $skinKey, $masterKeys ) )
{
$skinMasterKey = $skinKey;
$setID = 0;
}
//-----------------------------------------
// XML
//-----------------------------------------
@@ -1616,7 +1883,7 @@ class skinImportExport extends skinCaching
if ( ! is_array( $templateGroups ) OR ! count( $templateGroups ) )
{
$this->_addMessage( "Нечего экспортировать для приложения " . $app );
$this->_addMessage( $this->lang->words['nothingtoexportfor'] . $app );
return FALSE;
}
@@ -1624,8 +1891,8 @@ class skinImportExport extends skinCaching
// Fetch templates
//-----------------------------------------
$_templates = $this->fetchTemplates( $setID, 'allNoContent' );
$_MASTER = $this->fetchTemplates( 0, 'allNoContent' );
$_templates = $this->fetchTemplates( $setID , 'allNoContent' );
$_MASTER = $this->fetchTemplates( $skinMasterKey, 'allNoContent' );
//-----------------------------------------
// Loop through...
@@ -1664,9 +1931,9 @@ class skinImportExport extends skinCaching
// Wipe the master skins
//-----------------------------------------
if ( $setID == 0 )
if ( in_array( $skinKey, $masterKeys ) )
{
$this->DB->delete( 'skin_templates', "template_set_id=0 AND template_group IN ('" . implode( "','", array_keys( $templates ) ) . "') AND template_user_added=0 AND template_added_to=0" );
$this->DB->delete( 'skin_templates', "template_master_key='" . $skinKey . "' AND template_group IN ('" . implode( "','", array_keys( $templates ) ) . "') AND template_user_added=0 AND template_added_to=0" );
/* Now wipe the array so we enforce creation */
unset( $templates );
@@ -1703,6 +1970,7 @@ class skinImportExport extends skinCaching
'template_data' => $data['template_data'],
'template_user_edited' => $isEdited,
'template_user_added' => $isAdded,
'template_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
'template_updated' => time() ), 'template_set_id=' . $setID . " AND template_group='" . $data['template_group'] . "' AND template_name='" . $data['template_name'] . "'" );
}
else
@@ -1719,6 +1987,7 @@ class skinImportExport extends skinCaching
'template_added_to' => $setID,
'template_user_edited' => $isEdited,
'template_user_added' => $isAdded,
'template_master_key' => ( in_array( $skinKey, $masterKeys ) ) ? $skinKey : '',
'template_updated' => time() ) );
}
}
+10 -1
View File
@@ -1 +1,10 @@
<html> <head><title>IP.Board - Bulletin Board System</title></head> <body> <h1>403: IP.Board -> Forbidden</h1> <hr> You have reached this page in error, please use your back button to return to the forum. <hr> <a href="http://www.invisionboard.com/">IP.Board</a> </body> </html>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
File diff suppressed because it is too large. Load diff
+10 -1
View File
@@ -1 +1,10 @@
<html> <head><title>IP.Board - Bulletin Board System</title></head> <body> <h1>403: IP.Board -> Forbidden</h1> <hr> You have reached this page in error, please use your back button to return to the forum. <hr> <a href="http://www.invisionboard.com/">IP.Board</a> </body> </html>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -1,19 +1,21 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Recurse Tier Management
* Owner: Matt Mecham
* Last Updated: $Date: 2009-12-08 09:35:22 -0500 (Tue, 08 Dec 2009) $
* Last Updated: $Date: 2010-09-13 05:53:37 -0400 (Mon, 13 Sep 2010) $
* </pre>
*
* @author $Author: matt $
* @author $Author: terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 5531 $
* @version $Revision: 6854 $
*/
class recursiveTiers
@@ -146,6 +148,15 @@ class recursiveTiers
*/
protected $_sqlWhere = '';
/**
* SQL Fields: Select information
*
* @access protected
* @var string
*/
protected $_sqlSelect = '*';
/**
* Custom method to build the tiers (can prevent SQL query)
*
@@ -165,6 +176,7 @@ class recursiveTiers
* 'sqlFolderFlag' (the SQL table field that tells if the row is a folder or not *Optional)
* 'sqlTitle' (the SQL table field for the item title)
* 'sqlOrder' (the SQL table field(s) to order on or by)
* 'sqlSelect' (the SQL table select fields (* by default))
* 'sqlTable' (the SQL table name)
* 'sqlWhere' (Any additional 'where' information *Optional) ]
* @return void
@@ -189,6 +201,7 @@ class recursiveTiers
$this->_sqlOrder = isset( $settings['sqlOrder'] ) ? $settings['sqlOrder'] : '';
$this->_sqlTable = isset( $settings['sqlTable'] ) ? $settings['sqlTable'] : '';
$this->_sqlWhere = isset( $settings['sqlWhere'] ) ? $settings['sqlWhere'] : '';
$this->_sqlSelect = isset( $settings['sqlSelect'] ) ? $settings['sqlSelect'] : '*';
$this->_customBuildMethod = isset( $settings['customMethod'] ) ? $settings['customMethod'] : '';
/* Build the tiers */
@@ -256,7 +269,7 @@ class recursiveTiers
$this->_sqlOrder = $this->_sqlOrder ? $this->_sqlOrder : $this->_sqlTitle;
$this->DB->build( array( 'select' => '*',
$this->DB->build( array( 'select' => $this->_sqlSelect,
'where' => $this->_sqlWhere,
'from' => $this->_sqlTable,
'order' => $this->_sqlOrder ) );
@@ -465,7 +478,7 @@ class recursiveTiers
* @param array Array of IDs to skip
* @return array
*/
private function _fetchDirectoriesDropDown($root_id, $jump_string="", $depth_guide="",$selected_id, $skip_id=array())
private function _fetchDirectoriesDropDown($root_id, $jump_string="", $depth_guide="", $selected_id, $skip_id=array())
{
//-----------------------------------------
// Got an array?
@@ -498,7 +511,7 @@ class recursiveTiers
$jump_string .= "<option value=\"{$item_data[$this->_sqlPrimaryID]}\"".$selected.">&nbsp;&nbsp;&#039;".$depth_guide." ".$item_data[$this->_sqlTitle]."</option>\n";
}
$jump_string = $this->_fetchDirectoriesDropDown( $item_data[$this->_sqlPrimaryID], $jump_string, $depth_guide . '--', $html, $selected_id, $skip_id );
$jump_string = $this->_fetchDirectoriesDropDown( $item_data[$this->_sqlPrimaryID], $jump_string, $depth_guide . '--', $selected_id, $skip_id );
}
}
@@ -607,7 +620,7 @@ class recursiveTiers
* @param array Array of IDs to skip
* @return string
*/
private function _fetchAllsItemDropDown($root_id, $jump_string="", $depth_guide="",$selected_id, $skip_id=array())
private function _fetchAllsItemDropDown($root_id, $jump_string="", $depth_guide="", $selected_id, $skip_id=array())
{
if ( is_array( $this->_itemCache[ $root_id ] ) )
{
@@ -636,7 +649,7 @@ class recursiveTiers
$jump_string .= "<option value=\"{$item_data[$this->_sqlPrimaryID]}\"".$selected.">&nbsp;&nbsp;&#0124;".$depth_guide." ".$item_data[$this->_sqlTitle]."</option>\n";
$jump_string = $this->_fetchAllsItemDropDown( $item_data[$this->_sqlPrimaryID], $jump_string, $depth_guide . '--', $html, $selected_id, $skip_id );
$jump_string = $this->_fetchAllsItemDropDown( $item_data[$this->_sqlPrimaryID], $jump_string, $depth_guide . '--', $selected_id, $skip_id );
}
}
@@ -0,0 +1,717 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Twitter Connect Library
* Created by Matt Mecham
* Last Updated: $Date: 2010-10-27 11:07:09 -0400 (Wed, 27 Oct 2010) $
* </pre>
*
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @version $Rev: 7052 $
*
*/
class twitter_connect
{
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $DB;
protected $settings;
protected $lang;
protected $member;
protected $memberData;
protected $cache;
protected $caches;
/**#@-*/
/**
* Twitter OAUTH wrapper
*
* @access private
* @var object
*/
private $_api;
/**
* IPBs log in handler
*
* @access private
* @var object
*/
private $_login;
/**
* User connected
*
* @access private
* @var boolean
*/
private $_connected = false;
/**
* User: Token
*
* @access private
* @var string
*/
private $_userToken;
/**
* User: Secret
*
* @access private
* @var string
*/
private $_userSecret;
/**
* User: Data
*
* @access private
* @var array
*/
private $_userData = array();
/**
* Construct.
* $this->memberData['twitter_token'] $this->memberData['twitter_secret']
* @access public
* @return void
*/
public function __construct( $registry, $token='', $secret='' )
{
/* 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();
define("CONSUMER_KEY" , trim( ipsRegistry::$settings['tc_token'] ) );
define("CONSUMER_SECRET", trim( ipsRegistry::$settings['tc_secret'] ) );
define("OAUTH_CALLBACK" , $this->settings['_original_base_url'] . '/interface/twitter/index.php?m=' . $this->memberData['member_id'] );
/* @todo : Remove this in 3.2 just a tmp fix for 3.1.3 */
$this->request['_reg'] = ( isset( $this->request['reg'] ) ) ? $this->request['reg'] : $this->request['_reg'];
/* Auto do it man */
if ( ! $token AND $this->memberData['member_id'] AND $this->memberData['twitter_token'] )
{
$token = $this->memberData['twitter_token'];
$secret = $this->memberData['twitter_secret'];
}
$this->_userToken = trim( $token );
$this->_userSecret = trim( $secret );
/* Test */
if ( ! CONSUMER_KEY OR ! CONSUMER_SECRET )
{
throw new Exception( 'TWITTER_NOT_SET_UP' );
}
/* Set include path.. */
@set_include_path( IPS_KERNEL_PATH . 'twitter/' . PATH_SEPARATOR . ini_get( 'include_path' ) );
/* Reset the API */
$this->resetApi( $token, $secret );
}
/**
* Resets API
*
* @access public
* @param string OAUTH user token
* @param string OAUTH user secret
*/
public function resetApi( $token='', $secret='' )
{
$this->_userToken = trim( $token );
$this->_userSecret = trim( $secret );
/* Load API */
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $this->_userToken, $this->_userSecret );
if ( $this->_userToken AND $this->_userSecret )
{
$_userData = $this->_api->get('account/verify_credentials');
if ( $_userData['id'] )
{
$this->_userData = $_userData;
$this->_connected = true;
}
else
{
$this->_userData = array();
$this->_connected = false;
}
}
else
{
$this->_userData = array();
$this->_connected = false;
}
}
/**
* Return user data
*
* @access public
* @return array
*/
public function fetchUserData()
{
return $this->_userData;
}
/**
* Return whether or not the user is connected to twitter
*
* @access public
* @return boolean
*/
public function isConnected()
{
return ( $this->_connected == true ) ? true : false;
}
/**
* Post a status update to twitter based on native content
* Which may be longer and such and so on and so forth, etc
*
* @access public
* @param string Content
* @param string URL to add
* @param bool Always add the URL regardless of content length
*/
public function updateStatusWithUrl( $content, $url, $alwaysAdd=TRUE )
{
/* Ensure content is correctly de-html-ized */
$content = IPSText::UNhtmlspecialchars( $content );
/* Is the text longer than 140 chars? */
if ( $alwaysAdd === TRUE or IPSText::mbstrlen( $content ) > 140 )
{
/* Leave 26 chars for URL shortener */
if ( IPSText::mbstrlen( $content ) > 117 )
{
$content = IPSText::mbsubstr( $content, 0, 114 ) . '...';
}
/* Generate short URL */
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
$shorten = new urlShorten();
$data = $shorten->shorten( $url, 'bitly' );
return $this->updateStatus( $content . ' ' . $data['url'] );
}
else
{
/* Just post it */
return $this->updateStatus( $content );
}
}
/**
* Post a status update to twitter
*
* @access public
* @return mixed status id (int) successful, FALSE, #ftl
*/
public function updateStatus( $text )
{
if ( $text AND $this->isConnected() )
{
$status = $this->_api->post( 'statuses/update', array( 'status' => IPSText::convertCharsets( $text, IPS_DOC_CHAR_SET, 'utf-8' ) ) );
$code = $this->_api->http_code;
/* 200 is OK, 403 is returned if API limit is hit */
if ( $code == 200 AND $status['id'] )
{
/* Update member */
if ( $this->memberData['member_id'] )
{
/* Update member */
IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'tc_last_sid_import' => $status['id'] ) ) );
}
return $status['id'];
}
else
{
return false;
}
}
return false;
}
/**
* Redirects a user to the oauth connect page.
*
* @access public
* @return redirect
*/
public function redirectToConnectPage()
{
/* Reset api to ensure user is not logged in */
$this->resetApi();
/* Append OAUTH URL */
$_urlExtra = '';
$key = '';
/* From registration/log in? */
if ( ! $this->memberData['member_id'] AND $this->request['_reg'] )
{
/* Create validating account for the member */
$key = md5( uniqid( microtime() ) );
/* Append URL with correct member ID and other params */
$_urlExtra = '&_reg=1&key=' . $key;
}
/* Generate oAuth token */
$rToken = $this->_api->getRequestToken( OAUTH_CALLBACK . $_urlExtra );
if ( $rToken['oauth_token'] AND $rToken['oauth_token_secret'] )
{
/* From registration? */
if ( $_urlExtra )
{
/* Create validating account for the member */
$this->DB->insert( 'twitter_connect', array( 't_key' => $key,
't_token' => $rToken['oauth_token'],
't_secret' => $rToken['oauth_token_secret'],
't_time' => time() ) );
}
/* Update user's row */
if ( $this->memberData['member_id'] )
{
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'twitter_token' => $rToken['oauth_token'],
'twitter_secret' => $rToken['oauth_token_secret'] ) ) );
}
if ( $this->_api->http_code == 200 )
{
$url = $this->_api->getAuthorizeURL( $rToken['oauth_token'] );
$this->registry->output->silentRedirect( $url );
}
else
{
print "There was an error connecting to Twitter";
exit();
}
}
else
{
/* Twitter application is not set up correctly */
$this->registry->output->showError( 'twitter_app_error', 0.717734 );
}
}
/**
* Completes the connection
*
* @access public
* @return redirect
*/
public function finishLogin()
{
/* From reg flag */
$connectData = array( 't_key' => '' );
if ( $_REQUEST['key'] )
{
$connectData = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'twitter_connect',
'where' => "t_key='" . IPSText::md5Clean( $_REQUEST['key'] ) . "'" ) );
if ( ! $connectData['t_key'] )
{
/* @todo something more useful here */
throw new Exception( "NO_KEY_FOUND" );
}
/* Delete connect row */
$this->DB->delete( 'twitter_connect', "t_key='" . IPSText::md5Clean( $_REQUEST['key'] ) . "'" );
$member = array( 'twitter_token' => $connectData['t_token'],
'twitter_secret' => $connectData['t_secret'] );
}
if ( $_REQUEST['oauth_token'] )
{
if ( $member['twitter_token'] == $_REQUEST['oauth_token'] )
{
/* Reset api to ensure user is not logged in */
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $member['twitter_token'], $member['twitter_secret'] );
/* Generate oAuth token */
$rToken = $this->_api->getAccessToken( $_REQUEST['oauth_verifier'] );
if ( $rToken['oauth_token'] AND $rToken['oauth_token_secret'] )
{
$_userData = $this->_api->get('account/verify_credentials');
/* From registration? */
if ( $connectData['t_key'] )
{
/* Got a member linked already? */
$_member = IPSMember::load( $_userData['id'], 'all', 'twitter_id' );
if ( $_member['member_id'] )
{
$memberData = array_merge( $member, $_member );
/* Ensure user's row is up to date */
IPSMember::save( $memberData['member_id'], array( 'core' => array( 'twitter_token' => $rToken['oauth_token'],
'twitter_secret' => $rToken['oauth_token_secret'] ) ) );
/* Check for partial member id */
$pmember = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id'] ) );
if ( $pmember['partial_member_id'] )
{
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global&section=register&do=complete_login&mid='. $memberData['member_id'].'&key='.$pmember['partial_date'] );
}
else
{
/* Here, so log us in!! */
$this->_login()->loginWithoutCheckingCredentials( $memberData['member_id'], TRUE );
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] );
}
}
else
{
/* No? Create a new member */
/* Generate BW options */
foreach( array( 'tc_s_pic', 'tc_s_avatar', 'tc_s_status', 'tc_s_aboutme', 'tc_si_status' ) as $field )
{
$_toSave[ $field ] = 1;
}
$tc_bwoptions = IPSBWOptions::freeze( $_toSave, 'twitter' );
$safeFBName = str_replace( ' ', '', IPSText::convertCharsets( $_userData['screen_name'], 'utf-8', IPS_DOC_CHAR_SET ) );
$displayName = ( ! $this->settings['auth_allow_dnames'] ) ? $safeFBName : FALSE;
/* From reg, so create new account properly */
$toSave = array( 'core' => array( 'name' => $safeFBName,
'members_display_name' => $displayName,
'members_created_remote' => 1,
'member_group_id' => ( $this->settings['tc_mgid'] ) ? $this->settings['tc_mgid'] : $this->settings['member_group'],
'email' => '',
'twitter_id' => $_userData['id'],
'twitter_token' => $rToken['oauth_token'],
'twitter_secret' => $rToken['oauth_token_secret'] ),
'extendedProfile' => array( 'pp_about_me' => IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $_userData['description'], 'utf-8', IPS_DOC_CHAR_SET ) ),
'tc_photo' => $_userData['profile_image_url'],
'tc_bwoptions' => $tc_bwoptions,
'avatar_location' => $_userData['profile_image_url'],
'avatar_type' => 'twitter' ) );
$memberData = IPSMember::create( $toSave, TRUE, FALSE, FALSE );
if ( ! $memberData['member_id'] )
{
throw new Exception( 'CREATION_FAIL' );
}
$pmember = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . $memberData['member_id'] ) );
if ( $pmember['partial_member_id'] )
{
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global&section=register&do=complete_login&mid='. $memberData['member_id'].'&key='.$pmember['partial_date'] );
}
else
{
throw new Exception( 'CREATION_FAIL' );
}
}
}
}
}
}
}
/**
* Completes the connection
*
* @access public
* @return redirect
*/
public function finishConnection()
{
if ( $_REQUEST['m'] AND $_REQUEST['oauth_token'] )
{
/* Load user */
$member = IPSMember::load( intval( $_REQUEST['m'] ) );
if ( $member['twitter_token'] == $_REQUEST['oauth_token'] )
{
/* Reset api to ensure user is not logged in */
require_once( IPS_KERNEL_PATH . 'twitter/twitteroauth.php' );
$this->_api = new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, $member['twitter_token'], $member['twitter_secret'] );
/* Generate oAuth token */
$rToken = $this->_api->getAccessToken( $_REQUEST['oauth_verifier'] );
if ( $rToken['oauth_token'] AND $rToken['oauth_token_secret'] )
{
$_userData = $this->_api->get('account/verify_credentials');
/* Ensure user's row is up to date */
IPSMember::save( $member['member_id'], array( 'core' => array( 'twitter_id' => $_userData['id'],
'twitter_token' => $rToken['oauth_token'],
'twitter_secret' => $rToken['oauth_token_secret'] ) ) );
}
}
}
/* Redirect back to settings page */
$this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp&tab=members&area=twitter' );
}
/**
* Finish a log-in connection
* WARNING: NO PERMISSION CHECKS ARE PERFORMED IN THIS FUNCTION.
*
* @access public
* @param int Forum ID of original member (member to keep)
* @param int Forum ID of linking member (member to remove)
* @return boolean
*/
public function finishNewConnection( $originalId, $newId )
{
if ( $originalId AND $newId )
{
$original = IPSMember::load( $originalId, 'all' );
$new = IPSMember::load( $newId, 'all' );
if ( $original['member_id'] AND $new['twitter_id'] AND $new['twitter_token'] AND $new['twitter_secret'] )
{
IPSMember::save( $original['member_id'], array( 'core' => array( 'twitter_id' => $new['twitter_id'], 'twitter_token' => $new['twitter_token'], 'twitter_secret' => $new['twitter_secret'] ) ) );
return true;
}
}
return false;
}
/**
* Function to resync a member's Twitter data
*
* @access public
* @param mixed Member Data in an array form (result of IPSMember::load( $id, 'all' ) ) or a member ID
* @return array Updated member data
*
* EXCEPTION CODES:
* NO_MEMBER Member ID does not exist
* NOT_LINKED Member ID or data specified is not linked to a FB profile
*/
public function syncMember( $memberData )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$exProfile = array();
/* Do we need to load a member? */
if ( ! is_array( $memberData ) )
{
$memberData = IPSMember::load( intval( $memberData ), 'all' );
}
/* Got a member? */
if ( ! $memberData['member_id'] )
{
throw new Exception( 'NO_MEMBER' );
}
/* Linked account? */
if ( ! $memberData['twitter_id'] )
{
throw new Exception( 'NOT_LINKED' );
}
/* Not completed sign up ( no display name ) */
if ( $memberData['member_group_id'] == $this->settings['auth_group'] )
{
return false;
}
/* Thaw Options */
$bwOptions = IPSBWOptions::thaw( $memberData['tc_bwoptions'], 'twitter' );
/* Grab the data */
try
{
$this->resetApi( $memberData['twitter_token'], $memberData['twitter_secret'] );
if ( $this->isConnected() )
{
$user = $this->fetchUserData();
/* Update.. */
$exProfile['tc_photo'] = ( $bwOptions['tc_s_pic'] ) ? $user['profile_image_url'] : '';
if ( $bwOptions['tc_s_avatar'] )
{
$exProfile['avatar_location'] = $user['profile_image_url'];
$exProfile['avatar_type'] = 'twitter';
}
if ( $bwOptions['tc_s_aboutme'] )
{
$exProfile['pp_about_me'] = IPSText::getTextClass( 'bbcode' )->stripBadWords( IPSText::convertCharsets( $user['description'], 'utf-8', IPS_DOC_CHAR_SET ) );
}
if ( $bwOptions['tc_si_status'] AND ( isset( $memberData['gbw_no_status_import'] ) AND ! $memberData['gbw_no_status_import'] ) )
{
/* Fetch timeline */
$memberData['tc_last_sid_import'] = ( $memberData['tc_last_sid_import'] < 1 ) ? 100 : $memberData['tc_last_sid_import'];
$_updates = $this->fetchUserTimeline( $user['id'], $memberData['tc_last_sid_import'], true );
/* Got any? */
if ( count( $_updates ) )
{
$update = array_shift( $_updates );
if ( is_array( $update ) AND isset( $update['text'] ) )
{
/* Load status class */
if ( ! $this->registry->isClassLoaded( 'memberStatus' ) )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus' );
$this->registry->setClass( 'memberStatus', new $classToLoad( ipsRegistry::instance() ) );
}
/* Set Author */
$this->registry->getClass('memberStatus')->setAuthor( $memberData );
/* Convert if need be */
if ( IPS_DOC_CHAR_SET != 'UTF-8' )
{
$update['text'] = IPSText::utf8ToEntities( $update['text'] );
}
/* Set Content */
$this->registry->getClass('memberStatus')->setContent( trim( IPSText::getTextClass( 'bbcode' )->stripBadWords( $update['text'] ) ) );
/* Set as imported */
$this->registry->getClass('memberStatus')->setIsImport( 1 );
/* Set creator */
$this->registry->getClass('memberStatus')->setCreator( 'twitter' );
/* Can we reply? */
if ( $this->registry->getClass('memberStatus')->canCreate() )
{
$this->registry->getClass('memberStatus')->create();
$exProfile['tc_last_sid_import'] = $update['id'];
}
}
}
}
/* Allowed profile customization? */
if ( $bwOptions['tc_s_bgimg'] AND ( $user['profile_background_image_url'] OR $user['profile_background_color'] ) AND ( $this->memberData['gbw_allow_customization'] AND ! $this->memberData['bw_disable_customization'] ) )
{
/* remove bg images */
IPSMember::getFunction()->removeUploadedBackgroundImages( $memberData['member_id'] );
$exProfile['pp_customization'] = serialize( array( 'bg_url' => $user['profile_background_image_url'],
'type' => ( $user['profile_background_image_url'] ) ? 'url' : 'color',
'bg_color' => IPSText::alphanumericalClean( $user['profile_background_color'] ),
'bg_tile' => intval( $user['profile_background_tile'] ) ) );
}
/* Update member */
IPSMember::save( $memberData['member_id'], array( 'core' => array( 'tc_lastsync' => time() ),
'extendedProfile' => $exProfile ) );
/* merge and return */
$memberData['tc_lastsync'] = time();
$memberData = array_merge( $memberData, $exProfile );
}
}
catch( Exception $e )
{
}
return $memberData;
}
/**
* Fetch a user's recent status updates (max 50)
*
* @access public
* @param int Twitter ID
* @param bool Strip @replies (true default)
* @param int Minimum ID to grab from
* @return array
*/
public function fetchUserTimeline( $userId=0, $minId=0, $stripReplies=true )
{
$userId = ( $userId ) ? $userId : $this->_userData['id'];
$count = 50;
$final = array();
$updates = $this->_api->get('statuses/user_timeline', array( 'id' => $userId, 'count' => 50, 'since_id' => $minId ) );
if ( is_array( $updates ) AND count( $updates ) )
{
foreach( $updates as $update )
{
if ( substr( $update['text'], 0, 1 ) != '@' )
{
$final[] = $update;
}
}
}
return $final;
}
/**
* Accessor for the log in functions
*
* @access public
* @return object
*/
public function _login()
{
if ( ! is_object( $this->_login ) )
{
require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' );
$this->_login = new han_login( $this->registry );
$this->_login->init();
}
return $this->_login;
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,73 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-22 10:10:04 -0500 (Fri, 22 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5742 $
*/
/* Class name must match shortener directory name */
class bitly extends urlShorten
{
private $_config = array();
private $_cfm;
/**
* Method constructor
*
* If you pass false as the key, it will not save out the imported GUIDs
* @access public
* @return void
*
*/
public function __construct( $config=array() )
{
$this->_config = $config;
require_once( IPS_KERNEL_PATH . 'classFileManagement.php' );
$this->_cfm = new classFileManagement();
$this->_cfm->use_sockets = 1;
$this->_cfm->timeout = 30;
}
/**
* Shorten URL
*
* @access public
* @param string URL to shorten
* @return array ( 'status' => [ok/failed], 'url' => [shortened url], 'method' => [api used], 'raw' => [any raw data] )
* Exception codes:
*/
public function apiShorten( $url )
{
/* Query the service */
$response = $this->_cfm->getFileContents( "http://api.bit.ly/shorten?version=2.0.1&longUrl=" . urlencode( $url ) . "&login={$this->_config['login']}&apiKey={$this->_config['apiKey']}" );
if ( ! $response )
{
return array( 'status' => 'failed' );
}
$obj = json_decode( $response, TRUE );
return array( 'status' => 'ok',
'url' => $obj['results'][$url]['shortUrl'],
'method' => 'bitly',
'raw' => $obj['results'] );
}
}
@@ -0,0 +1,28 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5713 $
*/
$config = array();
/* Login... */
$config['login'] = 'invisionps';
/* API KEY - You can find your apiKey at http://bit.ly/account/your_api_key : */
$config['apiKey'] = 'R_eee8c282b147b0aed1bce4370ac81744';
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,193 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* URL Shortener
* Owner: Matt Mecham
* Last Updated: $Date: 2010-01-15 10:18:44 -0500 (Fri, 15 Jan 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 24th November 2009
* @version $Revision: 5713 $
*/
/*
Example: Shorten URL
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
$shorten = new urlShorten();
$data = $shorten->shorten( 'http://www.invisionpower.com', 'bitly' );
print $data['url'];
Example: List available shorteners
require_once( IPS_ROOT_PATH . 'sources/classes/url/shorten.php' );
$shorten = new urlShorten();
print_r( $shorten->fetchAvailableApis() );
*/
class urlShorten
{
/**
* Main API classes directory
*
* @access public
* @var object
*/
private $_mainDir;
/**
* API class
*
* @access public
* @var object
*/
private $_api;
/**
* Additional error messages
*
* @access public
* @var array
*/
public $errors = array();
/**
* Method constructor
*
* @access public
* @return void
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
*/
public function __construct()
{
$this->_mainDir = IPS_ROOT_PATH . 'sources/classes/url/apis';
}
/**
* Shorten URL
*
* @access public
* @param string URL to shorten
* @param string Method key to use (If left blank, we'll just grab the first one)
* @return array
*
* EXCEPTION MESSAGES
* NO_METHOD API class could not be found
* BAD_FORMAT URL is not in the correct format
* FAILED URL shorten failed
*/
public function shorten( $url, $apiKey )
{
/* Check URL */
if ( ! strstr( $url, 'http://' ) AND ! strstr( $url, 'https://' ) )
{
throw new Exception( 'BAD_FORMAT' );
}
if ( $apiKey )
{
$_thisDir = $this->_mainDir . '/' . $apiKey;
if ( @file_exists( $_thisDir . '/api.php' ) )
{
$this->_setMethod( $apiKey );
}
}
else
{
/* We don't care */
$apis = $this->fetchAvailableApis();
if ( is_array( $apis ) AND count( $apis ) )
{
$apiKey = array_shift( $apis );
if ( $apiKey )
{
$this->_setMethod( $apiKey );
}
}
}
if ( ! is_object( $this->_api ) )
{
throw new Exception( 'NO_METHOD' );
}
/* still here? */
$data = $this->_api->apiShorten( $url );
if ( $data['status'] == 'ok' )
{
return $data;
}
else
{
/* could do something more useful here */
throw new Exception( 'FAILED' );
}
}
/**
* Set method
* Assumes that the folder and files exist
*
* @access private
* @param string
*/
private function _setMethod( $apiKey )
{
$config = array();
if ( file_exists( $this->_mainDir . '/' . $apiKey . '/conf.php' ) )
{
require( $this->_mainDir . '/' . $apiKey . '/conf.php' );
}
require_once( $this->_mainDir . '/' . $apiKey . '/api.php' );
$this->_api = new $apiKey( $config );
}
/**
* Fetch all available APIs
*
* @access public
* @return array
*/
public function fetchAvailableApis()
{
$apis = array();
try
{
foreach( new DirectoryIterator( $this->_mainDir ) as $file )
{
if ( ! $file->isDot() AND $file->isDir() )
{
$_name = $file->getFileName();
if ( substr( $_name, 0, 1 ) != '.' )
{
$apis[] = $_name;
}
}
}
} catch ( Exception $e ) {}
return $apis;
}
}
@@ -1 +1,10 @@
<html> <head><title>IP.Board - Bulletin Board System</title></head> <body> <h1>403: IP.Board -> Forbidden</h1> <hr> You have reached this page in error, please use your back button to return to the forum. <hr> <a href="http://www.invisionboard.com/">IP.Board</a> </body> </html>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
Loaded 100 of 2563 files, more files were not shown because too many files have changed in this diff. Show more