Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

Rekomendowane odpowiedzi

Opublikowano

Witajcie, nietypowe pytanie, zanim zgłoszę się do autora modyfikacji. Czy Wam, również od momentu przejścia na najnowszą wersję (1.2.7) pojawiły się problemy z forum? Mam tutaj w sumie na myśli wzrost generowanego obciążenia. Nie wiem, może robię coś źle, ale w momencie włączenia hooka Shoutbox (Global) z wersji 1.2.7 obciążenie generowane przez forum rośnie, do granic takich że VPS'owi brakuje zasobów i skutkuje to takim faktem że php w wersji fpm (5.3.10-1~dotdeb.1) odcina workery i nie przyjmuje żądać - co w sumie jest zabiegiem celowy, ale nie o tym.

Spotkaliście się z takim "problemem"? Dodam że ten hook z starej wersji (1.2.4) działa poprawnie przy najnowszej wersji sb, ale chyba nie chodzi o to żeby się bawić w jakieś podmianki....

Opublikowano

Tylko na głównej. Ilekroć odpalam standardowy moduł (1.2.7) tylekroć po 5-10min workery php'a przestają działać, load 20 i w skrócie kupa :-) Autor modyfikacji w sumie zbył mnie stwierdzeniem:

Version 1.2.7 specifically addressed things that were causing high server load (short refresh rates, long times before refreshes would stop, loading lots of emoticons on every page), so if anything it should be an improvement over previous versions.

Przeglądałem zawartość hooka i zasadniczo to różni się niewiele, dodana jest cała klasa member i warunek:

if ( !empty( $_GET['forcePrint'] ) && ( $_GET['_k'] == $this->member->form_hash ) )

Co do którego w wielkim skrócie mam wątpliwości, na jakiego grzyba on tutaj. Dodatkowo dwa warunki więcej w filtrowanych podstronach i usunięcie ładowania emotek - czego w sumie też nie rozumiem, aczkolwiek sprawdzam tylko hooka, możliwe że robione jest to w innym miejscu. Teraz pytanie, bo mam ciut przestarzałą wersję 1.2.4 hooka, nie ma ktoś całkiem przypadkiem pliku global_shoutbox.xml z wersji 1.2.6?

  • Manager
Opublikowano

Teraz pytanie, bo mam ciut przestarzałą wersję 1.2.4 hooka, nie ma ktoś całkiem przypadkiem pliku global_shoutbox.xml z wersji 1.2.6?

Jako, że nie wklejamy kodów całych plików, więc daję 'tylko' jego fragment:

<?xml version="1.0" encoding="utf-8"?>
<hookexport>
 <hookfiles>
<file>
  <hook_file_real>shoutboxGlobalShoutbox.php</hook_file_real>
  <hook_type>templateHooks</hook_type>
  <hook_classname>shoutboxGlobalShoutbox</hook_classname>
  <hook_data><![CDATA[a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_global";s:12:"skinFunction";s:14:"globalTemplate";s:4:"type";s:2:"if";s:2:"id";s:15:"mainpageContent";s:8:"position";s:11:"pre.startif";}]]></hook_data>
  <hooks_source><![CDATA[<?php

class shoutboxGlobalShoutbox
{
protected $registry;
protected $settings;
protected $request;
protected $member;
protected $memberData;
protected $cache;

public function __construct()
{
	/* Make registry objects */
	$this->registry   =  ipsRegistry::instance();
	$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();
}

public function getOutput()
{
	/* Check temporary ban status */
	if( $this->memberData['temp_ban'] )
	{
		# Let's just return, it is useless to process it since it is already done in ipsRegistry
		return;
	}

	/* Check the new way to ban */
	if ( $this->memberData['member_banned'] == 1 )
	{
		return;
	}

	/* No permission to view the board */
	if ( $this->memberData['g_view_board'] != 1 )
	{
		return;
	}

	/* Offline or can't view? */
	if ( !$this->settings['shoutbox_online'] || !$this->memberData['g_shoutbox_view'] || (!$this->memberData['g_shoutbox_view'] && !$this->memberData['g_shoutbox_use']) || ( $this->settings['board_offline'] && !$this->memberData['g_access_offline'] ) )
	{
		return;
	}

	/** Shoutbox app? - Are we shoutbox banned? **/
	if ( ipsRegistry::$current_application == 'shoutbox' || $this->memberData['_cache']['shoutbox_banned'] )
	{
		return;
	}

	/* Login enforced? */
	if ( !$this->memberData['member_id'] && $this->settings['force_login'] == 1 )
	{
		return;
	}

	/* Printing the page? */
	if ( !empty( $_GET['forcePrint'] ) && ( $_GET['_k'] == $this->member->form_hash ) )
	{
		return;
	}

	/* Display only on index page? */
	if ( $this->settings['shoutbox_global_display_loc'] == 'idx' )
	{
		// idx shortcut not used?
		if ( $this->request['act'] == 'idx' || (ipsRegistry::$current_application == 'forums' && ipsRegistry::$current_module == 'forums' && ipsRegistry::$current_section == 'boards') )
		{
			// Go on!
		}
		else
		{
			return;
		}
	}
	else
	{
		// Check pages?
		if ( !in_array( $this->settings['shoutbox_global_hook'], array( 's', 'ct', 'cb' ) ) && $this->pagesCheckList() )
		{
			return;
		}
	}

	/* Our library is loaded? */
	if( !class_exists('app_class_shoutbox') OR !$this->registry->isClassLoaded('shoutboxLibrary') )
	{
		require_once( IPSLib::getAppDir('shoutbox').'/app_class_shoutbox.php' );
		$app_class_shoutbox = new app_class_shoutbox( ipsRegistry::instance() );
	}

	$this->registry->getClass('shoutboxLibrary')->global_on = true;
	$this->registry->getClass('shoutboxLibrary')->_startup();

	// Check prefs
	if ( !$this->registry->getClass('shoutboxLibrary')->prefs['global_display'] )
	{
		return;
	}

	// We have the right amount of posts
	// to use it if we can use it?
	if ( $this->memberData['g_shoutbox_use'] && $this->memberData['g_shoutbox_posts_req'] )
	{
		$this->memberData['g_shoutbox_posts_req'] = intval($this->memberData['g_shoutbox_posts_req']);
		if ($this->memberData['g_shoutbox_posts_req'] && $this->memberData['posts'] < $this->memberData['g_shoutbox_posts_req'])
		{
			$this->memberData['g_shoutbox_use'] = 0;
			$this->registry->getClass('shoutboxLibrary')->moderator = 0;
		}
	}

	/* Time to load some emoticons, yup! */
	$emoArray = array();

	if ( $this->memberData['g_shoutbox_use'] && $this->settings['shoutbox_allow_smilies'] )
	{
		foreach( $this->cache->getCache('emoticons') as $emo )
		{
			if ( $emo['emo_set'] != $this->registry->getClass('output')->skin['set_emo_dir'] )
			{
				continue;
			}

			# Store them!
			$emoArray[] = array( 'text' => addslashes($emo['typed']), 'image' => $emo['image'] );
		}
	}

	$d = array( 'shout_height' => $this->registry->getClass('shoutboxLibrary')->prefs['shoutbox_gheight'],
				'announcement' => $this->registry->getClass('shoutboxLibrary')->_get_announcement(),
				'noshouts'	 => $this->registry->getClass('shoutboxLibrary')->_noShoutsMessage(),
				'shouts'	   => $this->registry->getClass('shoutboxLibrary')->return_shouts(true),
				'smilies'	  => $this->registry->getClass('shoutboxLibrary')->editor->fetchEmoticons(),
				'emoticons'	=> count($emoArray) ? $this->registry->getClass('output')->getTemplate('shoutbox_hooks')->hookGlobalShoutboxEmoticons( $emoArray ) : ''
				);

	/* Setup JS things */
	$d['js']  = $this->registry->getClass('output')->getTemplate('shoutbox')->javascript( $d );
	$d['js'] .= $this->registry->getClass('shoutboxLibrary')->show_lang_for_js_use();

	/* Which hook? - Added in 1.1.1 */
	if ( $this->settings['shoutbox_global_hook'] == 's' )
	{
		$hook = 'hookGlobalShoutboxSidebar';
	}
	else
	{
		# Not sidebar? Use the normal one then
		$hook = 'hookGlobalShoutbox';
	}

	return $this->registry->getClass('output')->getTemplate('shoutbox_hooks')->$hook( $d );
}

private function pagesGetList()
{
	$pages = array();

	foreach ( explode("\n", $this->settings['shoutbox_global_pages_list']) as $row )
	{
		// We have a row?
		$row = trim($row);
		if ($row == '')
		{
			continue;
		}

		// We have segments?
		$segments = explode(",", $row);
		if ( count($segments) <= 0 )
		{
			continue;
		}

		// Parse segments
		$list = array();
		foreach ( $segments as $v )
		{
			if ( preg_match("#(.+?)=(.+?)#i", $v) )
			{
				list($key, $value) = explode('=', $v);
				$list[ $key ] = $value;
			}
		}

		if ( count($list) )
		{
			$pages[] = $list;
		}
	}

	return $pages;
}

private function pagesCheckList()
{
	if ( $this->settings['shoutbox_global_pages_type'] == 'd' || $this->settings['shoutbox_global_pages_list'] == '' )
	{
		return false;
	}

	// Get pages from cache
	$pages = $this->pagesGetList();

	// Go through pages if we have some
	if ( count($pages) )
	{
		foreach ( $pages as $page )
		{
			/* Reset some vars */
			$totalParts = count($page);
			$foundParts = 0;

			foreach ( $page as $key => $value )
			{
				/* If we have a main key let's reset with the ipsRegistry values */
				if ( $key == 'app' )
				{
					$this->request[ $key ] = ipsRegistry::$current_application;
				}
				elseif ( $key == 'module' )
				{
					$this->request[ $key ] = ipsRegistry::$current_module;
				}
				elseif ( $key == 'section' )
				{
					$this->request[ $key ] = ipsRegistry::$current_section;
				}

				if ( $value == '*' && isset($this->request[ $key ]) )
				{
					$foundParts++;
				}
				elseif ( strtolower($this->request[ $key ]) == strtolower($value) )
				{
					$foundParts++;
				}
				else
				{
					break;
				}
			}

			if ( $foundParts == $totalParts )
			{
				return $this->settings['shoutbox_global_pages_type'] == 'e' ? TRUE : FALSE;
			}
		}
	}

	return $this->settings['shoutbox_global_pages_type'] == 'e' ? FALSE: TRUE;
}
}]]></hooks_source>
</file>
 </hookfiles>
 <hookextras_settings>
<setting>
  <conf_is_title>1</conf_is_title>
  <conf_title_title>Hook: Global Shoutbox</conf_title_title>
  <conf_title_desc/>
  <conf_title_noshow>1</conf_title_noshow>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_title_app>forums</conf_title_app>
  <conf_title_tab>Shoutbox</conf_title_tab>
</setting>
<setting>
  <conf_id>807</conf_id>
  <conf_title>Display on?</conf_title>
  <conf_description><![CDATA[select where to display the global shoutbox.<br /><strong style="color:blue">NOTE: This setting won't have any effect if you are using the sidebar hook</strong>]]></conf_description>
  <conf_group>77</conf_group>
  <conf_type>dropdown</conf_type>
  <conf_key>shoutbox_global_display_loc</conf_key>
  <conf_value/>
  <conf_default>all</conf_default>
  <conf_extra>all=Every Page
idx=Board Index Page</conf_extra>
  <conf_evalphp/>
  <conf_protected>1</conf_protected>
  <conf_position>4</conf_position>
  <conf_start_group/>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
<setting>
  <conf_id>808</conf_id>
  <conf_title>Hook to enable?</conf_title>
  <conf_description>Select which one of the hooks you want to enable</conf_description>
  <conf_group>77</conf_group>
  <conf_type>dropdown</conf_type>
  <conf_key>shoutbox_global_hook</conf_key>
  <conf_value/>
  <conf_default>t</conf_default>
  <conf_extra>t=Top of Each Page
b=Bottom of Each Page
s=Sidebar (Board Index Only)
ct=Above Forum Categories (Board Index Only)
cb=Below Forum Categories (Board Index Only)</conf_extra>
  <conf_evalphp><![CDATA[if ( $save == 1 || ( $this->request['do'] == 'setting_revert' && $this->request['id'] == $r['conf_id'] ) )
{
$_POST['shoutbox_global_hook'] = $_POST['shoutbox_global_hook'] ? $_POST['shoutbox_global_hook'] : $r['conf_default'];

switch( $_POST['shoutbox_global_hook'] )
{
	case 's': $newHookData = 'a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_boards";s:12:"skinFunction";s:18:"boardIndexTemplate";s:4:"type";s:7:"foreach";s:2:"id";s:11:"side_blocks";s:8:"position";s:9:"outer.pre";}'; break;
	case 'b': $newHookData = 'a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_global";s:12:"skinFunction";s:14:"globalTemplate";s:4:"type";s:2:"if";s:2:"id";s:15:"mainpageContent";s:8:"position";s:10:"post.endif";}'; break;
	case 't': $newHookData = 'a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_global";s:12:"skinFunction";s:14:"globalTemplate";s:4:"type";s:2:"if";s:2:"id";s:15:"mainpageContent";s:8:"position";s:11:"pre.startif";}'; break;
	case 'ct': $newHookData = 'a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_boards";s:12:"skinFunction";s:18:"boardIndexTemplate";s:4:"type";s:2:"if";s:2:"id";s:11:"cats_forums";s:8:"position";s:11:"pre.startif";}'; break;
	case 'cb': $newHookData = 'a:6:{s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_boards";s:12:"skinFunction";s:18:"boardIndexTemplate";s:4:"type";s:2:"if";s:2:"id";s:11:"cats_forums";s:8:"position";s:10:"post.endif";}'; break;
}

$this->DB->update( 'core_hooks_files', array( 'hook_data' => $newHookData ), "hook_classname='shoutboxGlobalShoutbox'" );
$this->cache->rebuildCache( 'hooks', 'global' );

require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );
require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );
$skinCaching = new skinCaching( $this->registry );
$skinCaching->flagSetForRecache();
}]]></conf_evalphp>
  <conf_protected>1</conf_protected>
  <conf_position>3</conf_position>
  <conf_start_group>Location Settings</conf_start_group>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
<setting>
  <conf_id>809</conf_id>
  <conf_title>Pages list</conf_title>
  <conf_description><![CDATA[Enter one command per line, separated with a comma.<br />
Commands should consist of application, module, and/or section values for that page, or anything that is part of the $_POST data for that particular page's URL.<br /><br />
For example, to include or exclude this from showing on the profile page for Member #1, use:<br />
app=members,module=profile,id=1]]></conf_description>
  <conf_group>77</conf_group>
  <conf_type>textarea</conf_type>
  <conf_key>shoutbox_global_pages_list</conf_key>
  <conf_value/>
  <conf_default/>
  <conf_extra/>
  <conf_evalphp/>
  <conf_protected>1</conf_protected>
  <conf_position>6</conf_position>
  <conf_start_group/>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
<setting>
  <conf_id>810</conf_id>
  <conf_title>Type of Page Check</conf_title>
  <conf_description><![CDATA[Page Check checks the address of the loaded page to see if you want to exclude or include the shoutbox there.<br /><strong style="color:blue">NOTE: This setting won't have any effect if you are using the sidebar hook</strong>]]></conf_description>
  <conf_group>77</conf_group>
  <conf_type>dropdown</conf_type>
  <conf_key>shoutbox_global_pages_type</conf_key>
  <conf_value/>
  <conf_default>d</conf_default>
  <conf_extra>d=DISABLE Page Check
e=EXCLUDE from specified pages
i=INCLUDE only in specified pages</conf_extra>
  <conf_evalphp/>
  <conf_protected>1</conf_protected>
  <conf_position>5</conf_position>
  <conf_start_group/>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
<setting>
  <conf_id>780</conf_id>
  <conf_title>Shouts display ordering</conf_title>
  <conf_description>Select which order to display the shouts.</conf_description>
  <conf_group>77</conf_group>
  <conf_type>dropdown</conf_type>
  <conf_key>shoutbox_global_shout_ordering</conf_key>
  <conf_value/>
  <conf_default>desc</conf_default>
  <conf_extra><![CDATA[asc=Older -> Newer
desc=Newer -> Older]]></conf_extra>
  <conf_evalphp/>
  <conf_protected>1</conf_protected>
  <conf_position>2</conf_position>
  <conf_start_group/>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
<setting>
  <conf_id>811</conf_id>
  <conf_title>Global Shoutbox Look</conf_title>
  <conf_description><![CDATA[select which global Shoutbox look to display.<br />Theme 1 - Input & buttons over to right of the shouts.<br />Theme 2 - Input is a single line and buttons are below the shouts.<br /><strong style="color:blue">NOTE: This setting won't have any effect if you are using the sidebar hook</strong>]]></conf_description>
  <conf_group>77</conf_group>
  <conf_type>dropdown</conf_type>
  <conf_key>shoutbox_global_theme</conf_key>
  <conf_value/>
  <conf_default>1</conf_default>
  <conf_extra>1=Theme 1
2=Theme 2</conf_extra>
  <conf_evalphp/>
  <conf_protected>1</conf_protected>
  <conf_position>1</conf_position>
  <conf_start_group>Display Settings</conf_start_group>
  <conf_add_cache>1</conf_add_cache>
  <conf_keywords/>
  <conf_title_keyword>shoutbox_hook_global</conf_title_keyword>
  <conf_is_title>0</conf_is_title>
</setting>
 </hookextras_settings>
 <hookextras_language/>
 <hookextras_modules/>
 <hookextras_help/>
 <hookextras_templates/>
 <hookextras_css/>
 <hookextras_tasks/>
 <hookextras_database_create/>
 <hookextras_database_alter/>
 <hookextras_database_update/>
 <hookextras_database_insert/>
</hookexport>

  • Lubię to 1

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

Opublikowano

Różnice między 1.2.6 a 1.2.7 to - o ile dobrze patrzę - tylko kwestia braku ładowania emotek, dodałem odpowiednie linijki w kodzie hooka, efekt? Działa bez najmniejszego problemu :-)

Problem więc rozwiązałem, dziwi mnie tylko fakt że nikt takiego problemu nie ma, prócz mnie (albo nikt o tym nie mówi).

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.