Example #1
0
<?php

namespace LosLog;

class LosZray
{
    public function storeLog($context, &$storage)
    {
        $msg = $context["functionArgs"][0];
        list($usec, $sec) = explode(" ", microtime());
        $date = date("Y-m-d H:i:s", $sec) . substr($usec, 1);
        $storage['LosLog'][] = array('date' => $date, 'message' => $msg);
    }
}
$losStorage = new \LosLog\LosZray();
$loslog = new \ZRayExtension("loslog");
$loslog->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'logo.png'));
$loslog->setEnabledAfter('Zend\\Mvc\\Application::init');
$loslog->traceFunction("LosLog\\Log\\StaticLogger::save", array($losStorage, 'storeLog'), function () {
});
Example #2
0
<?php

namespace Bewotec;

require __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Cms.php';
// Create new extension - disabled
$zre = new \ZRayExtension('Bewotec');
$zre->setEnabledAfter('Zend\\Mvc\\Application::init');
$cms = new Cms();
// @TODO: Adjust the class name
$zre->traceFunction('Application\\Controller\\IndexController::indexAction', function ($context, &$storage) {
}, array($cms, 'onLeaveIndexAction'));
// Collect information for the requests
// @TODO: Adjust the class name
//$zre->traceFunction('<ActualClassName>::doRequest',
$zre->traceFunction('Application\\Service\\Remote::doRequest', function ($context, &$storage) {
}, array($cms, 'onLeaveDoRequest'));
// Summarize that information
$zre->traceFunction('Bewotec\\Cms::shutdown', function ($context, &$storage) {
}, array($cms, 'onLeaveShutdown'));
register_shutdown_function(array($cms, 'shutdown'));
$zre->setMetadata(array(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'logo.png')));
            $item = strtolower($item) . '.php';
        });
        $reports = array();
        foreach ($folders as $folder) {
            $path = APPPATH . $folder . '/';
            $directoryIterator = new \RecursiveDirectoryIterator($path);
            foreach ($directoryIterator as $fileInfo) {
                if ($fileInfo->isFile() && in_array(strtolower($fileInfo->getFileName()), $loadedFiles)) {
                    $phpcsFile = $phpcs->processFile($fileInfo->getPathName());
                    $reportData = $phpcs->reporting->prepareFileReport($phpcsFile);
                    if (count($reportData['messages'])) {
                        foreach ($reportData['messages'] as $line => $_messages) {
                            foreach ($_messages as $message) {
                                foreach ($message as $msg) {
                                    $reports[] = array('filename' => str_replace(str_replace('\\', '/', FCPATH), '', str_replace('\\', '/', $reportData['filename'])), 'filepath' => $reportData['filename'], 'severity' => $msg['type'], 'line' => $line, 'message' => $msg['message']);
                                }
                            }
                        }
                    }
                }
            }
        }
        return $reports;
    }
}
$zre = new \ZRayExtension('CodeIgniter');
$zre->setEnabledAfter('CI_Loader::initialize');
$codeIgniter = new CodeIgniter();
$zre->traceFunction('CI_Output::_display', function () {
}, array($codeIgniter, 'init'));
$zre->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'logo.png'));
Example #4
0
<?php

$zre = new \ZRayExtension("Oro");
$zre->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'logo.png'));
$zre->setEnabledAfter('Oro\\Bundle\\DistributionBundle\\OroKernel::registerBundles');
$zre->traceFunction("Symfony\\Component\\HttpKernel\\Kernel::terminate", function () {
}, function ($context, &$storage) {
    $applicationContext = $context['this'];
    $container = $applicationContext->getContainer();
    $cm = $container->get('oro_config.global');
    $settingsFromAppConfig = $container->get('oro_config.config_definition_bag');
    $isInstalled = $container->hasParameter('installed') && $container->getParameter('installed');
    $currentConfiguration = [];
    if ($isInstalled) {
        foreach ($settingsFromAppConfig->all() as $bundleAlias => $settings) {
            foreach (array_keys($settings) as $settingName) {
                $key = implode('.', [$bundleAlias, $settingName]);
                $currentConfiguration[$key] = $cm->get($key);
            }
        }
    } else {
        $currentConfiguration['installed'] = false;
    }
    $storage['OroConfiguration'][] = $currentConfiguration;
});
Example #5
0
<?php

namespace PhpMetrics;

$zre = new \ZRayExtension('phpmetrics', true);
$zre->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'logo.png'));
// path SHOULD be absolute in zend server
// we cannot write following line:
// require_once __DIR__.'/vendor/autoload.php';
// COMPOSER AUTOLOAD DOESN'T WORK HERE
spl_autoload_register(function ($class) {
    $classes = (require '/usr/local/zend/var/plugins/phpmetrics/zray/vendor/composer/autoload_classmap.php');
    $filename = $classes[$class];
    // I don't know hyw Zend Server change path, but we should fix path here
    $filename = str_replace('phpmetrics/src', 'phpmetrics', $filename);
    require $filename;
});
require_once __DIR__ . '/Collector.php';
// create arbitrary function executed in last
function shutdown()
{
}
register_shutdown_function('PhpMetrics\\shutdown');
// listen this function
$zre->traceFunction('PhpMetrics\\shutdown', function () {
}, array(new Collector(), 'collect'));
Example #6
0
<?php

namespace OPcache;

require_once __DIR__ . DIRECTORY_SEPARATOR . 'OPcache.php';
$zre = new \ZRayExtension('opcache');
$zre->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'logo.png'));
$opcache = new OPcache();
$zre->setEnabledAfter('session_start');
$zre->traceFunction('session_start', array($opcache, 'startup'), array($opcache, 'shutdown'));
                $assignments = $cp->getAllAssignmentsForPage();
                foreach ($assignments as $assignment) {
                    $pk = $assignment->getPermissionKeyObject();
                    $obj = $pk->getPermissionObject();
                    if ($obj && (!isset($lastobj) || $lastobj != $obj)) {
                        $storage['customPagePermissions'][] = array('Type' => $obj->getPermissionObjectKeyCategoryHandle(), 'Object' => $obj->getPermissionObjectIdentifier());
                    }
                    $lastobj = $obj;
                }
            }
        }
    }
}
require __DIR__ . '/objects.php';
// Create new extension - disabled
$zre = new \ZRayExtension('concrete5');
$concrete5 = new Zray();
// set additional data such as logo
$zre->setMetadata(array('logo' => __DIR__ . DIRECTORY_SEPARATOR . 'double_logo.png'));
// start tracing only when 'your_application_initial_method' is called, e.g. 'Mage::run()'
$zre->setEnabledAfter('Concrete\\Core\\Application\\Application::checkPageCache');
// start everything
$zre->traceFunction('Concrete\\Core\\Application\\Application::checkPageCache', array($concrete5, 'start'), function () {
});
// trace config values checked and what their value was
$zre->traceFunction('Illuminate\\Config\\Repository::get', function () {
}, array($concrete5, 'onAfterGetConfigValue'));
// trace blocks
$zre->traceFunction('Concrete\\Core\\Page\\View\\PageView::startRender', array($concrete5, 'onBeforePageRender'), function () {
});
// trace block render time
Example #8
0
<?php

$zre = new \ZRayExtension('MyWp');
$zre->setEnabledAfter('wp_cache_close');
$zre->traceFunction('wp_cache_close', function () {
}, function ($context, &$storage) {
    if (!function_exists('get_plugins')) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    $pluginsData = get_plugins();
    $activePlugins = get_option('active_plugins');
    if (is_array($pluginsData) && count($pluginsData) > 0) {
        foreach ($pluginsData as $pluginKey => $pluginData) {
            $storage['default_panels'][] = array('name' => $pluginData['Name'], 'version' => $pluginData['Version'], 'active' => in_array($pluginKey, $activePlugins) ? 'Active' : 'Inactive');
        }
    }
    // duplicate the data for the new panel
    $storage['clean_html'] = $storage['default_panels'];
    $storage['simple_table'] = $storage['default_panels'];
    $storage['search_and_paging'] = $storage['default_panels'];
    $storage['summary_table'] = $storage['default_panels'];
});
Example #9
0
        $storage['defaultTree'][] = $context;
    }
    public function multExit($context, &$storage)
    {
        $storage['multiplyGeneralTree'][] = array('col1' => $context['functionArgs'][0], 'col2' => 'val2', 'params' => array(array('col1' => 'val1.1', 'col2' => 'val2.1', 'params' => 'aaa'), array('col1' => 'val1.2', 'col2' => 'val2.2', 'params' => 'bbb')));
    }
    public function productsExit($context, &$storage)
    {
        foreach ($context['returnValue'] as $product) {
            $storage['defaultTable'][] = $product;
            $storage['products'][$product['name']] = $product;
        }
    }
}
$zraySamples = new Samples();
$zre = new \ZRayExtension('Samples');
// enable the extension when this method called
$zre->setEnabledAfter('Samples::run');
// bind to run method
$zre->traceFunction('Samples::run', array($zraySamples, 'runEnter'), function () {
});
// bind to mult method
$zre->traceFunction('Samples::mult', function () {
}, array($zraySamples, 'multExit'));
// bind to mult method
$zre->traceFunction('Samples::getProducts', function () {
}, array($zraySamples, 'productsExit'));
// bind to stats method
$zre->traceFunction('Samples::stats', function ($context, &$storage) {
    $storage['stats'][] = array('name' => $context['functionArgs'][0], 'count' => $context['functionArgs'][1]);
}, function () {