Author: digitalnature - http://digitalnature.eu
Example #1
0
 /**
  * Setup ref
  * 
  * @return void
  */
 public static function init()
 {
     \ref::config('expLvl', 0);
     \ref::config('maxDepth', 10);
     \ref::config('showIteratorContents', TRUE);
     \ref::config('showPrivateMembers', TRUE);
 }
Example #2
0
/**
* Prepare a banner item for rendering
*
* @param    array   $A          banner details
* @param    ref     $template   reference of the banner template
*
*/
function prepare_banner_item($A, &$template)
{
    global $_CONF, $_USER, $LANG_ADMIN, $LANG_BANNER, $_IMAGE_TYPE, $LANG_DIRECTION;
    $url = COM_buildUrl($_CONF['site_url'] . '/banner/portal.php?what=banner&item=' . $A['bid']);
    $template->set_var('banner_url', $url);
    $template->set_var('banner_actual_url', $A['url']);
    $template->set_var('banner_actual_url_encoded', urlencode($A['url']));
    $template->set_var('banner_name', stripslashes($A['title']));
    $template->set_var('banner_name_encoded', urlencode($A['title']));
    $template->set_var('banner_hits', COM_numberFormat($A['hits']));
    $content = stripslashes($A['title']);
    $template->set_var('banner_html', $content);
    if (!COM_isAnonUser() && !SEC_hasRights('banner.edit')) {
        $reporturl = $_CONF['site_url'] . '/banner/index.php?mode=report&bid=' . $A['bid'];
        $template->set_var('banner_broken', COM_createLink($LANG_BANNER[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('banner_broken', '');
    }
    $bannerimg = nl2br(stripslashes($A['description']));
    $flg_link = empty($A['url']) ? false : true;
    $banner = banner_buildBanner($A['bid'], $content, $bannerimg, $flg_link);
    $template->set_var('banner_description', $banner);
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('banner.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/banner/index.php?mode=edit&bid=' . $A['bid'];
        $template->set_var('banner_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
        $attr = array('class' => 'editlink');
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl, $attr));
    } else {
        $template->set_var('banner_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #3
0
 public function startGroup($prefix = '')
 {
     $maxDepth = ref::config('maxDepth');
     if ($maxDepth > 0 && $this->level + 1 > $maxDepth) {
         $this->emptyGroup('...');
         return false;
     }
     $this->level++;
     $this->out .= '(';
     $this->indent += $this->levelPad[$this->level - 1];
     return true;
 }
Example #4
0
 public function endRoot()
 {
     $this->out .= "\n";
     if (($timeout = ref::getTimeoutPoint()) > 0) {
         $this->out .= sprintf("\n-- Listing incomplete. Timed-out after %4.2fs --\n", $timeout);
     }
 }
Example #5
0
<?php

// configuration for php-ref
ref::config('showMethods', false);
Example #6
0
 public function endExp()
 {
     if (ref::config('showBacktrace')) {
         $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         if (isset($traces[2])) {
             $trace = $traces[2];
             $this->out .= ' - ' . $trace['file'] . ':' . $trace['line'];
         }
     }
     $this->out .= "\n" . str_repeat('=', strlen($this->out)) . "\n";
 }
Example #7
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_LI_CONF, $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $A['url']);
    $template->set_var('link_name', $A['title']);
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $template->set_var('link_description', PLG_replaceTags(nl2br($A['description']), 'links', 'description'));
    $content = $A['title'];
    if ($_LI_CONF['target_blank'] == 1) {
        $attr = array('title' => $A['url'], 'class' => 'ext-link', 'target' => '_blank');
    } else {
        $attr = array('title' => $A['url'], 'class' => 'ext-link');
    }
    $html = COM_createLink($content, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?edit=x&amp;lid=' . $A['lid'];
        $template->set_var('edit_url', $editurl);
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"/>";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #8
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_CONF, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION, $_IMAGE_TYPE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $actualUrl = stripslashes($A['url']);
    $title = stripslashes($A['title']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $actualUrl);
    $template->set_var('link_actual_url_encoded', rawurlencode($actualUrl));
    $template->set_var('link_name', $title);
    $template->set_var('link_name_encoded', rawurlencode($title));
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $template->set_var('link_description', PLG_replaceTags(COM_nl2br(stripslashes($A['description']))));
    $attr = array('title' => $actualUrl);
    if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
        $class = 'ext-link';
        if (!empty($LANG_DIRECTION) && $LANG_DIRECTION == 'rtl') {
            $class .= '-rtl';
        }
        $attr['class'] = $class;
        if ($_LI_CONF['new_window']) {
            $attr['target'] = '_blank';
        }
    }
    $html = COM_createLink($title, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit&amp;lid=' . $A['lid'];
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #9
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_LI_CONF, $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE, $LANG_LOCALE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $A['url']);
    $template->set_var('link_name', $A['title']);
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $linkDesc = PLG_replaceTags(nl2br($A['description']), 'links', 'description');
    $template->set_var('link_description', $linkDesc);
    //                        PLG_replaceTags(nl2br($A['description']),'links','description'));
    $content = $A['title'];
    if ($_LI_CONF['target_blank'] == 1) {
        $attr = array('title' => $A['url'], 'class' => 'ext-link', 'target' => '_blank');
    } else {
        $attr = array('title' => $A['url'], 'class' => 'ext-link');
    }
    $html = COM_createLink($content, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?edit=x&amp;lid=' . $A['lid'];
        $template->set_var('edit_url', $editurl);
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"/>";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
    if ($_LI_CONF['linksperpage'] == 1) {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addMeta('property', 'og:site_name', urlencode($_CONF['site_name']));
        $outputHandle->addMeta('property', 'og:locale', isset($LANG_LOCALE) ? $LANG_LOCALE : 'en_US');
        $outputHandle->addMeta('property', 'og:title', $A['title']);
        $outputHandle->addMeta('property', 'og:type', 'website');
        $outputHandle->addMeta('property', 'og:url', $A['url']);
        if (preg_match('/<img[^>]+src=([\'"])?((?(1).+?|[^\\s>]+))(?(1)\\1)/si', $linkDesc, $arrResult)) {
            $outputHandle->addMeta('property', 'og:image', $arrResult[2]);
        }
    }
}
Example #10
0
/**
* Set the {lang_id} and {lang_attribute} variables for a template
*
* @param    ref     $template   template to use
* @return   void
* @note     {lang_attribute} is only set in multi-language environments.
*
*/
function COM_setLangIdAndAttribute(&$template)
{
    global $_CONF;
    $langAttr = '';
    $langId = '';
    if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
        $langId = COM_getLanguageId();
    } else {
        // try to derive the language id from the locale
        $l = explode('.', $_CONF['locale']);
        // get rid of character set
        $langId = $l[0];
        $l = explode('@', $langId);
        // get rid of '@euro', etc.
        $langId = $l[0];
    }
    if (!empty($langId)) {
        $l = explode('-', str_replace('_', '-', $langId));
        if (count($l) == 1 && strlen($langId) == 2) {
            $langAttr = 'lang="' . $langId . '"';
        } else {
            if (count($l) == 2) {
                if ($l[0] == 'i' || $l[0] == 'x') {
                    $langId = implode('-', $l);
                    $langAttr = 'lang="' . $langId . '"';
                } else {
                    if (strlen($l[0]) == 2) {
                        $langId = implode('-', $l);
                        $langAttr = 'lang="' . $langId . '"';
                    } else {
                        $langId = $l[0];
                        // this isn't a valid lang attribute, so don't set $langAttr
                    }
                }
            }
        }
    }
    $template->set_var('lang_id', $langId);
    if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
        $template->set_var('lang_attribute', ' ' . $langAttr);
    } else {
        $template->set_var('lang_attribute', '');
    }
}
Example #11
0
function print_vars($vars)
{
    if ($GLOBALS['cli']) {
        if (function_exists('rt')) {
            ref::config('shortcutFunc', array('print_vars'));
            ref::config('showUrls', FALSE);
            if (OBS_DEBUG > 0) {
                $trace = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
                ref::config('Backtrace', $trace);
                // pass original backtrace
                ref::config('showStringMatches', FALSE);
            } else {
                ref::config('showBacktrace', FALSE);
                ref::config('showResourceInfo', FALSE);
                ref::config('showStringMatches', FALSE);
                ref::config('showMethods', FALSE);
            }
            rt($vars);
        } else {
            print_r($vars);
        }
    } else {
        if (function_exists('r')) {
            ref::config('shortcutFunc', array('print_vars'));
            ref::config('showUrls', FALSE);
            if (OBS_DEBUG > 0) {
                $trace = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
                ref::config('Backtrace', $trace);
                // pass original backtrace
            } else {
                ref::config('showBacktrace', FALSE);
                ref::config('showResourceInfo', FALSE);
                ref::config('showStringMatches', FALSE);
                ref::config('showMethods', FALSE);
            }
            //ref::config('stylePath',  $GLOBALS['config']['html_dir'] . '/css/ref.css');
            //ref::config('scriptPath', $GLOBALS['config']['html_dir'] . '/js/ref.js');
            r($vars);
        } else {
            print_r($vars);
        }
    }
}
Example #12
0
<?php

ref::config('showPrivateMembers', true);
ref::config('expLvl', 3);
ref::config('showUrls', false);
// init app
$app = new \SlimController\Slim(array('templates.path' => dirname(__DIR__) . '/views', 'cookies.secret_key' => md5('appsecretkey'), 'controller.class_suffix' => '', 'controller.method_suffix' => '', 'controller.template_suffix' => 'twig', 'mode' => 'production', 'debug' => true));
if ($app->config('debug') === true) {
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
    $app->config('whoops.editor', 'sublime');
    $app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
}
/** Create monolog logger and store logger in container as singleton
 * (Singleton resources retrieve the same log resource definition each time)
 *  $app->log->info("Log error");
 *  try catch hook
 *  $app->applyHook('log.request.info', $e->getMessage());
 *  $app->log->error($e);
 */
$app->container->singleton('log', function () use($app) {
    $logpath = APP_PATH . '/app/logs/' . date('Y/m');
    $logfile = $logpath . '/' . date('d') . '.log';
    $old = umask(0);
    if (!is_dir($logpath)) {
        mkdir($logpath, 0777, true);
    }
    if (!is_writable($logpath)) {
        chmod($logfile, 0777);
    }
    if (!file_exists($logfile)) {
Example #13
0
<?php

if (isset($_GET['mode'])) {
    $htmlMode = $_GET['mode'] !== 'text';
    require dirname(__DIR__) . '/ref.php';
    require __DIR__ . '/example.class.php';
    ref::config('showPrivateMembers', true);
    ref::config('showIteratorContents', true);
    ref::config('showUrls', true);
    ref::config('showBacktrace', false);
    /**
     * Test class
     */
    final class Today extends \Tests\ClassTest
    {
    }
    /**
     * Test function
     *
     * @param   $test  Test argument
     * @return  void   Nothing
     */
    function today($test)
    {
    }
    $closedCurlRes = curl_init();
    curl_close($closedCurlRes);
    $array = array('hèllo world' => '(͡°͜ʖ͡°)', 'empty string' => '', 'multiline string' => "first line and some padding   \nsecond line", 'infinity' => INF, 'regular expression (pcre)' => '/^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$/', 'multi' => array(1, 2, 3, array(4, 5, 6), 'FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU'), 'matching class' => 'DateTime', 'matching file' => 'file.txt', 'incomplete object' => unserialize('O:3:"Foo":1:{s:3:"bar";i:5;}'), 'empty object' => new \StdClass(), 'closed CURL resource' => $closedCurlRes, 'matching date/file/function/class' => 'today', 'url' => 'http://google.com');
    $array['reference to self'] =& $array;
    $obj = new \Tests\ClassTest(array('foo', 'bar'), $array);
    if ($htmlMode) {
Example #14
0
<?php

if (isset($_GET['mode'])) {
    $htmlMode = $_GET['mode'] !== 'text';
    require dirname(__DIR__) . '/ref.php';
    require __DIR__ . '/example.class.php';
    ref::config('showPrivateMembers', true);
    ref::config('showIteratorContents', true);
    /**
     * Test class
     */
    final class Today extends \Tests\ClassTest
    {
    }
    /**
     * Test function
     *
     * @param   $test  Test argument
     * @return  void   Nothing
     */
    function today($test)
    {
    }
    $array = array('hèllo world' => '(͡°͜ʖ͡°)', 'empty string' => '', 'multiline string' => "first line and some padding   \nsecond line", 'infinity' => INF, 'regular expression (pcre)' => '/^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$/', 'multi' => array(1, 2, 3, array(4, 5, 6), 'FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU'), 'matching class' => 'DateTime', 'matching file' => 'file.txt', 'incomplete object' => unserialize('O:3:"Foo":1:{s:3:"bar";i:5;}'), 'empty object' => new \StdClass(), 'matching date/file/function/class' => 'today');
    $array['reference to self'] =& $array;
    $obj = new \Tests\ClassTest(array('foo', 'bar'), $array);
    if ($htmlMode) {
        r(true, false, 'I can haz a 강남스타일 string', '1492-10-14 04:20:00 America/Nassau', null, 4.2);
        r(array(), $array, serialize(array('A', 'serialized', 'string')));
        r(fopen('php://stdin', 'r'), function ($x, $d) {
        });
Example #15
0
 /**
  * Get styles and javascript (only generated for the 1st call)
  *
  * @return  string
  */
 public static function getAssets()
 {
     // first call? include styles and javascript
     if (static::$didAssets) {
         return '';
     }
     ob_start();
     if (ref::config('stylePath') !== false) {
         ?>
         <style>
             <?php 
         readfile(str_replace('{:dir}', __DIR__, ref::config('stylePath')));
         ?>
         </style>
         <?php 
     }
     if (ref::config('scriptPath') !== false) {
         ?>
         <script>
             <?php 
         readfile(str_replace('{:dir}', __DIR__, ref::config('scriptPath')));
         ?>
         </script>
         <?php 
     }
     // normalize space and remove comments
     $output = preg_replace('/\\s+/', ' ', trim(ob_get_clean()));
     $output = preg_replace('!/\\*.*?\\*/!s', '', $output);
     $output = preg_replace('/\\n\\s*\\n/', "\n", $output);
     static::$didAssets = true;
     return $output;
 }