Exemple #1
0
function loadAllPlugins()
{
    $pluginSet = array();
    /*Loads all plugins, does basic PHP check to ensure that there are no fatal PHP errors.*/
    if ($handle = opendir('plugins')) {
        /* This is the correct way to loop over the directory. */
        while (false !== ($entry = readdir($handle))) {
            $plugin = loadPlugin($entry);
            if ($plugin != null) {
                $pluginSet[] = $plugin;
            }
        }
        closedir($handle);
    }
    return $pluginSet;
}
Exemple #2
0
 protected function init()
 {
     /* 载入APP的配置文件 */
     tag('appConfLoad');
     if (file_exists(APP_PATH . '/conf/conf.php')) {
         $config = (require APP_PATH . '/conf/conf.php');
         config('', $config, 'merge');
     }
     tag('appConfLoaded');
     tag('appFunctionsLoad');
     /* 载入APP的函数集 */
     if (file_exists(APP_PATH . '/common/functions.php')) {
         require APP_PATH . '/common/functions.php';
     }
     tag('appFunctionsLoaded');
     /**
      * 载入APP的插件
      * 只载入后缀是Plugin.class.php的文件
      */
     tag('appPluginsLoad');
     if (file_exists(APP_PATH . '/plugins')) {
         $dir = dir(APP_PATH . '/plugins');
         while (($pluginName = $dir->read()) !== false) {
             /* 检查文件的后缀是否是Plugin.class.php */
             if (is_file(APP_PATH . '/plugins/' . $pluginName) && substr($pluginName, -16) === 'Plugin.class.php') {
                 loadPlugin(APP_PATH . '/plugins/' . $pluginName);
             }
         }
     }
     tag('appPluginsLoaded');
     /**
      * 载入路由
      */
     tag('appRoutesLoad');
     if (file_exists(APP_PATH . '/conf/routes.php')) {
         require APP_PATH . '/conf/routes.php';
     }
     tag('appRoutesLoad');
     defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', 'Index');
     defined('METHOD_NAME') or define('METHOD_NAME', 'index');
 }
Exemple #3
0
    } elseif (BC_INSTALLED && !$isMaintenance && (!empty($bcSite['version']) && getVersion() > $bcSite['version'])) {
        header('Location: ' . topLevelUrl(false) . baseUrl() . 'maintenance/index');
        exit;
    }
    Configure::write('BcRequest.isUpdater', $isUpdater);
}
/**
 * プラグインをCake側で有効化
 * 
 * カレントテーマのプラグインも読み込む
 */
if (BC_INSTALLED && !$isUpdater && !$isMaintenance) {
    App::build(array('Plugin' => array_merge(array(BASER_THEMES . $bcSite['theme'] . DS . 'Plugin' . DS), App::path('Plugin'))));
    $plugins = getEnablePlugins();
    foreach ($plugins as $plugin) {
        loadPlugin($plugin['Plugin']['name'], $plugin['Plugin']['priority']);
    }
    $plugins = Hash::extract($plugins, '{n}.Plugin.name');
    Configure::write('BcStatus.enablePlugins', $plugins);
    /**
     * イベント登録
     */
    App::uses('BcControllerEventDispatcher', 'Event');
    App::uses('BcModelEventDispatcher', 'Event');
    App::uses('BcViewEventDispatcher', 'Event');
    $CakeEvent = CakeEventManager::instance();
    $CakeEvent->attach(new BcControllerEventDispatcher());
    $CakeEvent->attach(new BcModelEventDispatcher());
    $CakeEvent->attach(new BcViewEventDispatcher());
    /**
     * テーマの bootstrap を実行する
Exemple #4
0
<?php

include_once '../include/ucp.php';
if (!$user->isValid()) {
    redirect('login.php');
} else {
    if (!$user->isEnabled()) {
        redirect('disabled.php');
    } else {
        loadPlugin('ucp', 'scratchcard');
        $sc = new ScratchCard();
        $currentDate = new DateTime('midnight');
        $startDate = new DateTime('first day of this month midnight');
        $endDate = new DateTime('first day of next month midnight');
        $withdrawalDay = configgetvalue('system', 'cash', NULL, 'withdrawalDay');
        $withdrawalDay -= 1;
        if ($withdrawalDay) {
            $startDate->modify("+{$withdrawalDay} day");
            $endDate->modify("+{$withdrawalDay} day");
        }
        if ($currentDate < $startDate) {
            $startDate->modify("-1 month");
            $endDate->modify("-1 month");
        }
        $currency = configgetvalue('system', 'main', NULL, 'currency');
        $tariffPrice = smoneyf($user->calculateTariffPrice());
        $formattedTariffPrice = sprintf(_ngettext("%s {$currency}", "%s {$currency}", $tariffPrice), $tariffPrice);
        $fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
        if (isset($_POST['code'])) {
            $paySum = $sc->pay($_POST['code'], $user->getId());
            if ($paySum) {
 /**
  * プラグインを読み込む
  * Blogプラグインでテストする前提
  * TODO 一部未完成 引数$priorityが機能していないバグ?があります
  * 
  * 
  * @param	string	$plugin プラグイン名
  * @dataProvider loadPluginDataProvider
  */
 public function testLoadPlugin($plugin, $priority, $expect)
 {
     // Eventテスト準備
     if ($expect) {
         $EventFolderPath = CakePlugin::path($plugin) . 'Event' . DS;
         $EventFilePath = $EventFolderPath . $plugin . 'Controller' . 'EventListener' . '.php';
         $Folder = new Folder();
         $Folder->create($EventFolderPath);
         $EventFile = new File($EventFilePath, true);
         $EventFile->write("<?php\nclass BlogControllerEventListener extends BcControllerEventListener {\n\tpublic \$events = array('hogeFunction');\n}");
         $EventFile->close();
     }
     // 他のテストに影響がでるためバックアップをとる
     $buckupPlugins = CakePlugin::loaded();
     $buckupBlog = Configure::read('BcApp.adminNavi.blog');
     Configure::delete('BcApp.adminNavi.blog');
     CakePlugin::unload();
     // プラグインを読み込む
     $result = loadPlugin($plugin, $priority);
     $this->assertEquals($expect, $result);
     if ($expect) {
         $EventFile->close();
         $Folder->delete($EventFolderPath);
         // プラグインが読み込めているか
         $this->assertContains($plugin, CakePlugin::loaded(), 'プラグインを読み込めません');
         $this->assertNotNull(Configure::read('BcApp.adminNavi.blog'), 'プラグインの設定が正しく設定されていません');
         $this->Event = new CakeEventManager();
         $EventListeners = $this->Event->listeners('Controller.hogeFunction');
         // イベントリスナーに登録されているか
         $this->assertContains('hogeFunction', $EventListeners[0]['callable'], 'プラグインイベントを正しく登録できません');
         // プライオリティを設定できているか
         if (!is_null($priority)) {
             $this->assertEquals($priority, $EventListeners[1]['callable'][0]->events['hogeFunction']['priority']);
         }
     }
     // バックアップを復元
     Configure::write('BcApp.adminNavi.blog', $buckupBlog);
     foreach ($buckupPlugins as $key => $value) {
         CakePlugin::load($value);
     }
 }
Exemple #6
0
<?php

/* Main file. */
require 'includes/global.php';
$params = explode('/', $_SERVER['REQUEST_URI']);
$args = array('controller' => $params[1 + $pathOffset], 'action' => $params[2 + $pathOffset], 'id' => $params[3 + $pathOffset]);
unset($params);
// Non-needed array reduces memory footprint
loadPlugin($args);
die(print_r($args));
function loadPlugin($args)
{
    //print 'loading '.$args['controller'].' with action '.$args['action'].' and id '.$args['id'];
    $path = 'plugins/' . $args['controller'] . '/index.php';
    if (file_exists($path)) {
        include $path;
        if (!$pluginData['nonOOP']) {
            $obj = new $pluginData['className']();
            $obj->init($args);
            // On second thought, can't we just handle the class and it take over at the constructor part? Sure. No ashanks, you're wrong. We've got to pass the args array to init.
        } else {
            call_user_func('init', $args);
        }
    }
}
Exemple #7
0
define('ROOT', '../../');
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');
require_once ROOT . '../private_html/config.php';
require_once ROOT . '../private_html/includes/database.php';
require_once ROOT . '../private_html/includes/func.php';
cacheCurrentPage();
// Our json encoded response
$response = array();
if (!isset($_GET['plugin'])) {
    $response['msg'] = 'No plugin provided';
    $response['status'] = 'err';
    exit(json_encode($response));
}
$plugin = loadPlugin($_GET['plugin']);
if ($plugin === null) {
    $response['msg'] = 'Invalid plugin';
    $response['status'] = 'err';
    exit(json_encode($response));
}
// Add some basic data
$response['name'] = $plugin->getName();
// resend them the name so it is case-correct
$response['author'] = $plugin->getAuthors();
$response['starts'] = $plugin->getGlobalHits();
$response['rank'] = $plugin->getRank();
// Server data
$response['servers'][24] = $plugin->getServerCount();
try {
    $globalGraph = $plugin->getOrCreateGraph('Global Statistics');
if ($scale > 10 || $scale <= 0) {
    define('REAL_IMAGE_HEIGHT', IMAGE_HEIGHT);
    define('REAL_IMAGE_WIDTH', IMAGE_WIDTH);
    error_image('Invalid modifier');
} else {
    define('REAL_IMAGE_HEIGHT', IMAGE_HEIGHT * $scale);
    define('REAL_IMAGE_WIDTH', IMAGE_WIDTH * $scale);
}
if (!isset($_GET['plugin'])) {
    error_image('Error: No plugin provided');
}
// The plugin we are graphing
$pluginName = urldecode($_GET['plugin']);
// Load the json data from the api
// First, basic plugin data
$plugin = loadPlugin($pluginName);
// Is the plugin invalid?
if ($plugin == null) {
    // no plugin found
    error_image('Invalid plugin');
}
// case-correct plugin name
$pluginName = $plugin->getName();
// get the graph from cache
$cacheKey = 'signature-' . $scale . '-' . $pluginName;
$cacheFileLocation = '../cache/' . $cacheKey . '.png';
if (!file_exists($cacheFileLocation)) {
    require ROOT . '../private_html/pChart/pData.class.php';
    require ROOT . '../private_html/pChart/pChart.class.php';
    require ROOT . '../private_html/pChart/pCache.class.php';
    // Create a new data set
Exemple #9
0
require_once ROOT . '../private_html/config.php';
require_once ROOT . '../private_html/includes/database.php';
require_once ROOT . '../private_html/includes/func.php';
cacheCurrentPage();
// Cache until the next interval
header('Cache-Control: public, s-maxage=' . (timeUntilNextGraph() - time()));
if (!isset($_GET['plugin'])) {
    $page_title = 'MCStats :: Invalid Plugin';
    $breadcrumbs = '<a href="/" class="current">Invalid Plugin</a>';
    send_header();
    echo '<div class="alert alert-error" style="margin-top: 15px">Invalid plugin name provided!</div>';
    send_footer();
    exit;
}
// Load the plugin
$plugin = loadPlugin(urldecode($_GET['plugin']));
// Doesn't exist
if ($plugin === null) {
    $page_title = 'MCStats :: Invalid Plugin';
    $breadcrumbs = '<a href="/" class="current">Invalid Plugin</a>';
    send_header();
    echo '<div class="alert alert-error" style="margin-top: 15px">Invalid plugin name provided!</div>';
    send_footer();
    exit;
}
// Get the plugin name
$pluginName = htmlentities($plugin->getName());
$encodedName = urlencode($pluginName);
// encoded name, for use in signature url
$more = '';
if (is_loggedin() && in_array($plugin, get_accessible_plugins(false))) {
Exemple #10
0
/**
 * Check if the given plugin can be accessed.
 *
 * @param $plugin Plugin or string
 * @return TRUE if the player can administrate the plugin
 */
function can_admin_plugin($plugin)
{
    if ($plugin instanceof Plugin) {
        $plugin_obj = $plugin;
    } else {
        if ($plugin instanceof string) {
            $plugin_obj = loadPlugin($plugin);
        }
    }
    // is it null??
    if ($plugin_obj == null) {
        return false;
    }
    // iterate through our accessible plugins
    foreach (get_accessible_plugins() as $a_plugin) {
        if ($a_plugin->getName() == $plugin_obj->getName()) {
            return $a_plugin->getPendingAccess() !== true;
        }
    }
    return false;
}
Exemple #11
0
<?php

include "../process.php";
$plugin = $_POST["plugin"];
if ($plugin) {
    echo loadPlugin($plugin);
}
Exemple #12
0
<?php

/**
* @version		1.5.0
* @package		Fiyo CMS
* @copyright	Copyright (C) 2012 Fiyo CMS.
* @license		GNU/GPL, see LICENSE.txt
**/
defined('_FINDEX_') or die('Access Denied');
//load active plugins
loadPlugin();
Exemple #13
0
     $response->header = array(array('id', 'varchar'), array('name', 'varchar'));
     $response->data = $assocTzlist;
     $response->success = true;
     break;
 case 'generatescratch':
     //$response=new response;
     if (!isset($_GET['count']) && !isset($_GET['value']) && !intval($_GET['count']) && !intval($_GET['value'])) {
         $response->success = false;
     }
     loadPlugin('acp', 'scratchcard');
     $sc = new ScratchCard($response);
     $sc->generate(intval($_GET['count']), intval($_GET['value']));
     $response = $sc->response;
     break;
 case 'getschema':
     loadPlugin('acp', 'schemacompare');
     $sc = new schemacompare();
     $response->header = array("databasePrefix" => DB_TABLE_PREFIX);
     $response->data = $sc->getSchema();
     break;
 case 'shownotifications':
     payment(1);
     return;
     break;
 case 'clearnotifications':
     payment(2);
     return;
     break;
 case 'payment':
     payment(0);
     return;
Exemple #14
0
        /* 检查文件的后缀是否是Plugin.class.php */
        if (is_file(SITE_PATH . '/model/' . $modelName) && substr($modelName, -15) === 'Model.class.php') {
            require_once SITE_PATH . '/model/' . $modelName;
        }
    }
}
/**
 * 载入插件
 * 只载入后缀是Plugin.class.php的文件
 */
if (file_exists(SITE_PATH . '/plugins')) {
    $dir = dir(SITE_PATH . '/plugins');
    while (($pluginName = $dir->read()) !== false) {
        /* 检查文件的后缀是否是Plugin.class.php */
        if (is_file(SITE_PATH . '/plugins/' . $pluginName) && substr($pluginName, -16) === 'Plugin.class.php') {
            loadPlugin(SITE_PATH . '/plugins/' . $pluginName);
        }
    }
}
/**
 * 载入控制器
 */
$c = 'Index';
if (isset($_GET['c']) && is_string($_GET['c'])) {
    /* 过滤../之类跨目录路径 */
    $c = ucfirst(basename($_GET['c']));
}
$controllerClassName = $c . 'Controller';
$controllerFilename = SITE_PATH . '/controller/' . $c . 'Controller.class.php';
if (!file_exists($controllerFilename)) {
    trigger_error('控制器:' . APP_NAME . '不存在!', E_USER_ERROR);
Exemple #15
0
<?php

define('ROOT', './');
require_once ROOT . '../private_html/config.php';
require_once ROOT . '../private_html/includes/database.php';
require_once ROOT . '../private_html/includes/func.php';
$plugin1_name = $_GET['plugin1'];
$plugin2_name = $_GET['plugin2'];
$plugin1 = loadPlugin($plugin1_name);
$plugin2 = loadPlugin($plugin2_name);
if ($plugin1 == null || $plugin2 == null) {
    exit('Invalid plugins provided.');
}
// array of the plugins to compare
$plugins = array($plugin1, $plugin2);
// plugin-specific counts
printf("%s servers have used %s in the last hour. <br/>", number_format($plugin1->countServersLastUpdated(time() - SECONDS_IN_HOUR)), $plugin1->getName());
printf("%s servers have used %s in the last hour. <br/><br/>", number_format($plugin2->countServersLastUpdated(time() - SECONDS_IN_HOUR)), $plugin2->getName());
$min_epoch = time() - SECONDS_IN_HOUR;
// how many servers have Either of the plugins
$either_of = count_servers($plugins, $min_epoch, -1);
// how many servers have OneOf the plugins (but not both)
$one_of = count_servers($plugins, $min_epoch, 1);
// how many servers have Both of the plugins
$both_of = count_servers($plugins, $min_epoch, count($plugins));
printf("%s servers have EitherOf ( %s , %s ) in the last hour. <br/>", number_format($either_of), $plugin1->getName(), $plugin2->getName());
printf("%s servers have OneOf ( %s , %s ) in the last hour. <br/>", number_format($one_of), $plugin1->getName(), $plugin2->getName());
printf("%s servers have BothOf ( %s , %s ) in the last hour. <br/>", number_format($both_of), $plugin1->getName(), $plugin2->getName());
function count_servers($plugins, $min_epoch, $matches_required = -1)
{
    $plugin_ids = array();