| アイコンの説明 | |
|---|---|
![]() |
(パクぷり):どこかでみつけたりいただいたりしたお役立ちプリロードです。 |
![]() |
(マジぷり):ちょっと便利かも!というプリロードです。 |
![]() |
(ネタぷり):「おもしろいだけ」というネタプリロードです。 |
![]() |
(バグぷり):バグ対応にプリロードでチャレンジしてるネタプリです。 |
※ 「パクぷり」以外はオリジナルのプリロード(もしくはデリゲート)です。ご利用は自由ですが自己責任でご活用くださいませ。一切責任は持てません。<特にネタぷりとか。
07.09.24 21:36
ツンデレだそうで。(; ̄ー ̄A 汗・・・
5分で出来るかと思ったら7分かかったとかで。。。
載せといてって言われたので載せておきます。
もらいもの系なんですがあきらかに分類「ネタ」だよね??
さくしゃ:まりふぁな
5分で出来るかと思ったら7分かかったとかで。。。
載せといてって言われたので載せておきます。
もらいもの系なんですがあきらかに分類「ネタ」だよね??
さくしゃ:まりふぁな
<?php
if (!defined('XOOPS_ROOT_PATH')) exit;
class tsundere extends XCube_ActionFilter
{
function preBlockFilter()
{
$this->mRoot->mDelegateManager->add('Site.CheckLogin.Success', array($this, 'tsun'), XCUBE_DELEGATE_PRIORITY_10);
$this->mRoot->mDelegateManager->add('Site.Logout.Success', array($this, 'dere'), XCUBE_DELEGATE_PRIORITY_10);
}
function tsun(&$xoopsUser)
{
$msg = array (
'何ログインしてんの(怒',
'来ないでよ〜',
'もう来ないでって言ったのに'
);
$this->mRoot->mController->executeRedirect(XOOPS_URL . '/', 3, $msg[array_rand($msg)]);
}
function dere(&$xoopsUser)
{
$msg = array (
'え〜もうかえっちゃうの?',
'まだ居てよ〜',
'二度と来るなカス'
);
$this->mRoot->mController->executeRedirect(XOOPS_URL . '/', 3, $msg[array_rand($msg)]);
}
}
?>
[ Download ]
07.09.16 02:08
ユーザー情報を隠すプリロード
掲載元:http://xoopscube.org/modules/pukiwiki/?XOOPSCubeLegacy%2FProgrammingGuide%2FPreload%2FHowToBanAccessToUserinfo
掲載元:http://xoopscube.org/modules/pukiwiki/?XOOPSCubeLegacy%2FProgrammingGuide%2FPreload%2FHowToBanAccessToUserinfo
<?php
/**
* @file preload/UserinfoGuard.class.php
*/
if (!defined('XOOPS_ROOT_PATH')) exit();
class UserinfoGuard extends XCube_ActionFilter
{
function preFilter()
{
$root =& XCube_Root::getSingleton();
//
// Add my function as the first part priority to Legacypage.Userinfo.Access
// By that, my function will be called early than the user module.
//
$root->mDelegateManager->add('Legacypage.Userinfo.Access',
'UserinfoGuard::myfunc',
XCUBE_DELEGATE_PRIORITY_FIRST + 10);
}
function myfunc()
{
$root =& XCube_Root::getSingleton();
$user =& $root->mContext->mUser;
if ($user->isInRole('Site.GuestUser')) {
$root->mController->executeRedirect(XOOPS_URL, 1, "Access Denided!");
}
//
// Delegate of XCube calls all of added functions.
// Therefore, after this function, the regular function will be called.
//
}
}
?>
[ Download ]
07.09.16 02:07
更新があったテンプレートファイルを自動的に反映するプリロード
掲載元:http://sunday-lab-ja.blogspot.com/2007/03/template-automatic-update-site-preload.html
掲載元:http://sunday-lab-ja.blogspot.com/2007/03/template-automatic-update-site-preload.html
<?php
/**
* @version 1.0.1
*/
//
// [EN]
// This site preload reflects updated templates automatically for LegacyRender.
// (Altsys has the same feature. You should install Altsys!)
//
// [JA]
// 更新があったテンプレートファイルを自動的に反映するプリロード(altsysに同機能あり、入れときんさい!) ... LegacyRender 用
//
if (!defined('XOOPS_ROOT_PATH')) exit();
//
// Specify a dirname of the target module. When it is "", this preload targets all of active modules.
//
// [JA]
// ターゲットのモジュールの dirname を指定します。無指定のとき、全アクティブモジュールが対象
//
define('TEMPLATEAUTOUPDATE_TARGET_DIRNAME', "");
//
// Specify a name of the target tplset. When it is "", this preload uses the current tplset.
// But, it doesn't update default tplset, if you specify "default" directly.
//
// [JA]
// ターゲットの TPLSET 。無指定のとき、現在のテンプレートセットを使いますが、 default のときは無視します。 default を明示した場合のみ書き換えます。
//
define('TEMPLATEAUTOUPDATE_TARGET_TPLSET', "");
class TemplateAutoUpdate extends XCube_ActionFilter
{
function preBlockFilter()
{
$modulelist = array();
if (TEMPLATEAUTOUPDATE_TARGET_DIRNAME == "") {
$handler =& xoops_gethandler('module');
$criteria =& new Criteria('isactive',1);
$modules =& $handler->getObjects($criteria);
foreach ($modules as $module) {
$modulelist[] = $module->get('dirname');
}
}
else {
$modulelist[] = TEMPLATEAUTOUPDATE_TARGET_DIRNAME;
}
foreach ($modulelist as $dirname) {
$handler =& xoops_getmodulehandler('tplfile', 'legacyRender');
$criteria =& new CriteriaCompo();
if (TEMPLATEAUTOUPDATE_TARGET_TPLSET == "") {
if ($this->mRoot->mContext->mXoopsConfig['template_set'] == 'default')
return;
$criteria->add(new Criteria('tpl_tplset', $this->mRoot->mContext->mXoopsConfig['template_set']));
}
else {
$criteria->add(new Criteria('tpl_tplset', TEMPLATEAUTOUPDATE_TARGET_TPLSET));
}
$criteria->add(new Criteria('tpl_module', $dirname));
$tplfiles =& $handler->getObjects($criteria);
foreach ($tplfiles as $tplfile)
{
$file = "";
if ($tplfile->get('tpl_type') == 'module') {
$file = XOOPS_MODULE_PATH . "/" . $dirname . "/templates/" . $tplfile->get('tpl_file');
}
elseif ($tplfile->get('tpl_type') == 'block') {
$file = XOOPS_MODULE_PATH . "/" . $dirname . "/templates/blocks/" . $tplfile->get('tpl_file');
}
else {
continue;
}
if (!file_exists($file))
continue;
$mtime = filemtime($file);
if ($mtime > $tplfile->get('tpl_lastmodified') && $mtime > $tplfile->get('tpl_lastimported')) {
$tplfile->loadSource();
$tplfile->set('tpl_lastmodified', $mtime);
$tplfile->Source->set('tpl_source', file_get_contents($file));
if ($handler->insert($tplfile, true)) {
require_once XOOPS_ROOT_PATH . "/class/template.php";
$xoopsTpl =& new XoopsTpl();
$xoopsTpl->clear_cache('db:' . $tplfile->get('tpl_file'));
$xoopsTpl->clear_compiled_tpl('db:' . $tplfile->get('tpl_file'));
}
}
}
}
}
}
?>
[ Download ]
07.09.16 02:06
Basic認証プリロード
掲載元:http://xoopscube.jp/modules/xhnewbb/viewtopic.php?topic_id=4956&post_id=21439#forumpost21439
掲載元:http://xoopscube.jp/modules/xhnewbb/viewtopic.php?topic_id=4956&post_id=21439#forumpost21439
<?php
// ダイレクトアクセスをはじく
if (!defined('XOOPS_ROOT_PATH'))
exit();
/**
* @remark user モジュールに依存しています
*/
class BasicAuth extends XCube_ActionFilter
{
function preFilter()
{
// SetupUserデリゲートに自前のメソッドを追加
// user モジュールより認証が後ろになるようにプライオリティをセット
$this->mController->mSetupUser->add(array(&$this, "postSetupUser"), XCUBE_DELEGATE_PRIORITY_FINAL);
}
function postSetupUser(&$principal, &$controller, &$context)
{
// "なにかの認証"を終えていればこれ以上の処理は必要ない
// 注: !is_object($xoopsUser) より正確な方法
if ($context->mUser->mIdentity->isAuthenticated()) {
return;
}
// Basic 認証のデータがブラウザから送られてきていなければ、ダイアログを出す
if (!isset($_SERVER['PHP_AUTH_USER'])) {
$this->authenticate();
}
//-----------------------------------------------------------
// * checklogin を呼び出す *
// checklogin はリクエストオブジェクトを通じて uname と pass の確認を取るので
// リクエストオブジェクトを HttpRequest クラスと差し替えて、こちらが取得した情報を
// 受け取るように状況を変えてやる。
//-----------------------------------------------------------
// HttpRequest から、今回の作戦に使えそうな GenericRequest に差し替える
$this->mRoot->mContext->mRequest =& new XCube_GenericRequest();
// setRequest がないので直にセット。
// これで getRequest したとき $_REQUEST の情報ではなく、こっちが指定した情報を
// 受け取ることになる
$this->mRoot->mContext->mRequest->mAttributes['uname'] = $_SERVER['PHP_AUTH_USER'];
$this->mRoot->mContext->mRequest->mAttributes['pass'] = $_SERVER['PHP_AUTH_PW'];
// 失敗時に再度ダイアログを出すように Site.CheckLogin.Faile (イベント)に
// ダイアログ表示メソッドを追加
$this->mRoot->mDelegateManager->add("Site.CheckLogin.Fail", array(&$this, "authenticate"));
// チェックログイン実行
$this->mController->checkLogin();
exit();
}
function authenticate()
{
header("WWW-Authenticate: Basic realm=\"X Cube...\"");
header('HTTP/1.0 401 Unauthorized');
$this->mController->executeRedirect(XOOPS_URL, 1, _NOPERM);
exit();
}
}
?>
[ Download ]
07.09.16 02:05
<?php
if (!defined('XOOPS_ROOT_PATH')) exit();
require_once XOOPS_ROOT_PATH . "/modules/legacy/kernel/Legacy_LanguageManager.class.php";
class UTF8_Trial extends XCube_ActionFilter
{
function preBlockFilter()
{
$this->mController->mRoot->mDelegateManager->add('Legacy_HelpAction.CreateHelpSmarty', 'UTF8_Trial::_createHelpSmarty', XCUBE_DELEGATE_PRIORITY_FINAL);
}
function _createHelpSmarty(&$smarty)
{
if (is_object($smarty)) {
$smarty->register_postfilter("UTF8_Trial_postfilter");
}
}
}
function UTF8_Trial_postfilter($buff, &$smarty)
{
return mb_convert_encoding($buff, "UTF-8", "EUC-JP");
}
class Legacy_LanguageManager_Japanese extends Legacy_LanguageManager
{
var $_mRequireOnceCache = array();
function Legacy_LanguageManager_Japanese()
{
define(_CHARSET, 'UTF-8');
}
function _loadFile($filename)
{
if (file_exists($filename)) {
if(!isset($this->_mRequireOnceCache[$filename])) {
global $xoopsDB, $xoopsTpl, $xoopsRequestUri, $xoopsModule, $xoopsModuleConfig,
$xoopsModuleUpdate, $xoopsUser, $xoopsUserIsAdmin, $xoopsTheme,
$xoopsConfig, $xoopsOption, $xoopsCachedTemplate, $xoopsLogger, $xoopsDebugger;
$content = file_get_contents($filename);
$content = str_replace("<?php", "", $content);
$content = str_replace("?>", "", $content);
$content = mb_convert_encoding($content, 'utf-8', 'euc-jp');
eval($content);
$this->_mRequireOnceCache[$filename] = true;
}
return true;
}
return false;
}
function loadTextFile($section, $filename)
{
$filepath = $this->getFilepath($section, $filename);
$content = file_get_contents($filepath);
return mb_convert_encoding($content, 'utf-8', 'euc-jp');;
}
}
?>
[ Download ]
07.09.16 02:04
<?php
define("LEGACY_JAPANESE_ANTI_CHARSETMYSQL", true);
?>
[ Download ]
07.09.16 02:02
ゲストユーザアクセス時にトップページのテーマだけを変更するプリロード。
http://ryus.co.jp/modules/wordpress/index.php?p=91
http://ryus.co.jp/modules/wordpress/index.php?p=91
<?php
/**
* ryusSetGuestTopTheme
* @author Ryuji http://ryus.co.jp/
*/
class ryusSetGuestTopTheme extends XCube_ActionFilter
{
var $guest_top_theme_name = 'guesttop'; // edit your guest top theme
function preBlockFilter()
{
$this->mRoot->mDelegateManager->add('Legacypage.Top.Access', array(&$this, 'setGuestTopTheme'));
}
function setGuestTopTheme()
{
if(!$this->mRoot->mContext->mUser->mIdentity->isAuthenticated()){
$this->mRoot->mContext->setThemeName($this->guest_top_theme_name);
}
}
}
?>
[ Download ]
07.09.16 02:00
あばたーぎゃらりーのリメイク
<?php
// 2007年5月8日 14:57:13
if (!defined('XOOPS_ROOT_PATH')) {
exit;
}
class UserAvatarGallery extends XCube_ActionFilter
{
/**
* XOOPS_SIDEBLOCK_LEFT : 左ブロック
* XOOPS_SIDEBLOCK_RIGHT : 右ブロック
* XOOPS_CENTERBLOCK_LEFT : 中央左ブロック
* XOOPS_CENTERBLOCK_RIGHT : 中央右ブロック
* XOOPS_CENTERBLOCK_CENTER : 中央中央ブロック
*/
var $_mEntryIndex = XOOPS_CENTERBLOCK_LEFT;
/**
* モジュールの mid を配列で指定
* -1 : トップページ
*/
var $_mTargetModule = array(-1);
/**
* Site.Owner
* Site.Administrator
* Site.RegisteredUser
* Site.GuestUser
*/
var $_mRoles = array('Site.Administrator', 'Site.RegisteredUser');
var $_mCols = 3;
var $_mMax = 3;
function postFilter()
{
if ($this->mRoot->mContext->mModule != null) {
$mid = $this->mRoot->mContext->mXoopsModule->get('mid');
} else {
$mid = preg_match('#index\.php$#i', xoops_getenv('PHP_SELF')) ? -1 : 0;
}
if ($this->_getRoles() && (!sizeof($this->_mTargetModule) || in_array($mid, $this->_mTargetModule))) {
$handler =& xoops_gethandler('user');
$criteria =& new CriteriaCompo();
$criteria->add(new Criteria('user_avatar', '', '<>'));
$criteria->add(new Criteria('user_avatar', 'blank.gif', '<>'));
$objects =& $handler->getObjects($criteria);
if ($handler->getCount($criteria)) {
$content = '<table cellspacing="0">' . "\n";
$content .= ' <tr>' . "\n";
shuffle($objects);
foreach ($objects as $col => $obj) {
if ($this->_mMax && $col >= $this->_mMax) {
break;
}
if ($col && $col % $this->_mCols == 0) {
$content .= ' </tr>' . "\n";
$content .= ' <tr>' . "\n";
}
$content .= ' <td style="text-align: center;">' . "\n";
$content .= ' <img src="' . XOOPS_UPLOAD_URL . '/' . $obj->getShow('user_avatar') . '" alt="' . $obj->getShow('uname') . '">' . "\n";
$content .= ' </td>' . "\n";
}
$content .= ' </tr>' . "\n";
$content .= '</table>' . "\n";
$this->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][constant($this->_mEntryIndex)] = true;
$this->mRoot->mContext->mAttributes['legacy_BlockContents'][constant($this->_mEntryIndex)][] = array(
'name' => '',
'title' => 'User Avatar Gallery',
'content' => $content,
'weight' => 99,
);
}
}
}
function _getRoles()
{
$ret = false;
if (!is_array($this->_mRoles) || !sizeof($this->_mRoles)) {
$this->_mRoles = array('Site.Administrator');
}
foreach ($this->_mRoles as $role) {
$ret |= in_array($role, $this->mRoot->mContext->mUser->_mRoles);
}
return $ret;
}
}
?>
[ Download ]
07.09.16 01:59
とりあえず登録されているアバターを並べてみる「あばたーぎゃらりー」なぷり。
<?php
// 2007年5月8日 14:57:13
if (!defined('XOOPS_ROOT_PATH')) {
exit;
}
class UserAvatarGallery extends XCube_ActionFilter
{
/**
* XOOPS_SIDEBLOCK_LEFT : 左ブロック
* XOOPS_SIDEBLOCK_RIGHT : 右ブロック
* XOOPS_CENTERBLOCK_LEFT : 中央左ブロック
* XOOPS_CENTERBLOCK_RIGHT : 中央右ブロック
* XOOPS_CENTERBLOCK_CENTER : 中央中央ブロック
*/
var $_mEntryIndex = XOOPS_CENTERBLOCK_LEFT;
/**
* モジュールの mid を配列で指定
* -1 : トップページ
*/
var $_mTargetModule = array(-1);
/**
* Site.Owner
* Site.Administrator
* Site.RegisteredUser
* Site.GuestUser
*/
var $_mRoles = array('Site.Administrator', 'Site.RegisteredUser');
function postFilter()
{
if ($this->mRoot->mContext->mModule != null) {
$mid = $this->mRoot->mContext->mXoopsModule->get('mid');
} else {
$mid = preg_match('#index\.php$#i', xoops_getenv('PHP_SELF')) ? -1 : 0;
}
if ($this->_getRoles() && (!sizeof($this->_mTargetModule) || in_array($mid, $this->_mTargetModule))) {
$handler =& xoops_gethandler('user');
$criteria =& new CriteriaCompo();
$criteria->add(new Criteria('user_avatar', '', '<>'));
$criteria->add(new Criteria('user_avatar', 'blank.gif', '<>'));
$objects =& $handler->getObjects($criteria);
if ($handler->getCount($criteria)) {
$content = '<table cellspacing="0">' . "\n";
$content .= ' <tr>' . "\n";
foreach ($objects as $obj) {
$content .= ' <td style="text-align: center;">' . "\n";
$content .= ' <img src="' . XOOPS_UPLOAD_URL . '/' . $obj->getShow('user_avatar') . '" alt="' . $obj->getShow('uname') . '">' . "\n";
$content .= ' </td>' . "\n";
}
$content .= ' </tr>' . "\n";
$content .= '</table>' . "\n";
$this->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][constant($this->_mEntryIndex)] = true;
$this->mRoot->mContext->mAttributes['legacy_BlockContents'][constant($this->_mEntryIndex)][] = array(
'name' => '',
'title' => 'User Avatar Gallery',
'content' => $content,
'weight' => 99,
);
}
}
}
function _getRoles()
{
$ret = false;
if (!is_array($this->_mRoles) || !sizeof($this->_mRoles)) {
$this->_mRoles = array('Site.Administrator');
}
foreach ($this->_mRoles as $role) {
$ret |= in_array($role, $this->mRoot->mContext->mUser->_mRoles);
}
return $ret;
}
}
?>
[ Download ]
07.09.16 01:57
legacyに依存してRSS情報を配信するためのプリロード。これはこのサイトで使用しているmyBLOG用に作成したものですが、使いたいモジュールに合わせて多少書きかえていただければ他でも使えます。
もっとも若干の問題が。(苦笑)
表示件数が考慮されていないので、1000件の情報があれば1000件すべて列挙の暴挙。(笑)ためしに500件ほどダミーデータを作成してみましたが圧巻でした。(爆)
もちろん、配信モジュールや、受け手がリーダ側でそれなりに設定もできますが、そもそも根本的な制限がないのも如何ともしがたい感。区切れはすれど、一度はすべての情報が投げられるといいうことになるでしょうから無駄も多いかも?・・・BackendAction.class.phpで件数固定とか、legacyで件数を設定できるようにする、などということも考えてみてもいいかもしれないですね。
※これはサイトプリロードではなく、モジュールプリロードです。
もっとも若干の問題が。(苦笑)
表示件数が考慮されていないので、1000件の情報があれば1000件すべて列挙の暴挙。(笑)ためしに500件ほどダミーデータを作成してみましたが圧巻でした。(爆)
もちろん、配信モジュールや、受け手がリーダ側でそれなりに設定もできますが、そもそも根本的な制限がないのも如何ともしがたい感。区切れはすれど、一度はすべての情報が投げられるといいうことになるでしょうから無駄も多いかも?・・・BackendAction.class.phpで件数固定とか、legacyで件数を設定できるようにする、などということも考えてみてもいいかもしれないですね。
※これはサイトプリロードではなく、モジュールプリロードです。
<?php
// 2007年5月8日 12:58:46
if (!defined('XOOPS_ROOT_PATH')) {
exit;
}
class MyBLOG_Backend extends XCube_ActionFilter
{
function preBlockFilter()
{
$this->mRoot->mDelegateManager->add('Legacy_BackendAction.GetRSSItems', array(&$this, 'GetRSSItems'));
}
function GetRSSItems(&$items)
{
$dirname = basename(dirname(dirname(__FILE__)));
$handler =& xoops_getmodulehandler('databox', $dirname);
$objects =& $handler->getObjects();
foreach ($objects as $obj) {
$items[] = array(
'title' => $obj->getShow('title'),
'link' => XOOPS_MODULE_URL . '/' . $dirname . '/index.php?action=BlogView&id=' . $obj->getShow('id'),
'guid' => XOOPS_MODULE_URL . '/' . $dirname . '/index.php?action=BlogView&id=' . $obj->getShow('id'),
'pubdate' => $obj->getShow('date'),
'description' => '',
'category' => '',
'author' => $obj->getShow('uid') ? XoopsUser::getUnameFromId($obj->getShow('uid')) : $obj->getShow('name'),
);
}
}
}
?>
[ Download ]








