Example #1
0
function echo_errorlog()
{
    $_errorLogPath = M3_Util_Settings::getPhpErrorLogPathName();
    if ($_errorLogPath) {
        if (get_request_param("clearerrorlog")) {
            if (!M3_Util_File::truncateFile($_errorLogPath)) {
                echo "<i>Count not truncate error log [{$_errorLogPath}]</i>";
            }
        }
        echo <<<EOL1
        <h2 align="center">{$_errorLogPath}</h2>
        <table align="center"><tr><td>
        <form action="index.php">
           <input type="hidden" name="show" value="errorlog"/>
           <input type="hidden" name="clearerrorlog" value="true"/>
           <input type="submit" value="Clear"/>
        </form>
        </td></tr></table>
EOL1;
        echo "<pre>";
        echo htmlentities(file_get_contents($_errorLogPath));
        echo "</pre>";
    } else {
        echo "Cannot determine where the error log is";
    }
}
Example #2
0
/**
 *  Whatever Data is returned by Hanlder, should be an array will be rendered as array on response
 * 
 * @param AbstractUser $user
 * @param array $controllerInfo
 * @param String $handlerName
 */
function rx_interceptor_json($user, $controllerInfo, $handlerName)
{
    $user->validate();
    include_once RUDRA . "/core/handler/AbstractHandler.php";
    $handlerInfo = ClassUtil::getHandler($handlerName);
    if ($handlerInfo != NULL) {
        global $temp;
        include_once $handlerInfo["filePath"];
        $className = $handlerInfo["className"];
        $tempClass = new ReflectionClass($className);
        if ($tempClass->isInstantiable()) {
            $temp = $tempClass->newInstance();
        }
        if ($temp != NULL) {
            try {
                if ($tempClass->hasMethod("invokeHandler")) {
                    $resp = call_method_by_class($tempClass, $temp, 'invokeHandler', array('user' => $user, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]);
                    if (isset($resp)) {
                        echo json_encode($resp);
                    }
                }
            } catch (Exception $e) {
                echo json_encode(array("error" => $e));
            }
        }
    }
}
Example #3
0
function rx_interceptor_page($user, $info, $handlerName)
{
    $user->validate();
    include_once RUDRA . "/core/handler/AbstractHandler.php";
    $handlerInfo = ClassUtil::getHandler($handlerName);
    if ($handlerInfo != NULL) {
        global $temp;
        include_once $handlerInfo["filePath"];
        $className = $handlerInfo["className"];
        $tempClass = new ReflectionClass($className);
        if ($tempClass->isInstantiable()) {
            $temp = $tempClass->newInstance();
        }
        if ($temp != NULL) {
            if ($tempClass->hasMethod("invokeHandler")) {
                $tpl = new Smarty();
                call_user_func(rx_function("rx_set_smarty_paths"), $tpl);
                $tpl->debugging = RX_SMARTY_DEBUG;
                $header = new Header($tpl);
                $page = new Page();
                $view = call_method_by_class($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'header' => $header, 'page' => $page, 'dataModel' => $page->data, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]);
                if (!isset($view)) {
                    $view = $handlerName;
                }
                $tpl->assign('user', $user);
                $tpl->assign('page', $page);
                $tpl->assign('header', $header);
                $tpl->assign('CONTEXT_PATH', CONTEXT_PATH);
                $tpl->assign('RESOURCE_PATH', RESOURCE_PATH);
                $tpl->assign('METAS', $header->metas);
                $tpl->assign('TITLE', $header->title);
                $view_path = $view . TEMP_EXT;
                if (!file_exists($view_path)) {
                    $tpl->setTemplateDir(RUDRA . "/core/view");
                    //$view_path = get_include_path () . RUDRA . "/core/view/".$view.TEMP_EXT;
                    //$view_path = get_include_path () . RUDRA . "../view/".$view.TEMP_EXT;
                }
                $tpl->assign('BODY_FILES', $view_path);
                $tpl->assign('page_json', json_encode($page->data->data));
                $tpl->display(RUDRA . "/core/view/full.tpl");
                Browser::log("header", $header->css, $header->scripts);
                Browser::printlogs();
            }
        }
    }
}
Example #4
0
function echo_api_durations()
{
    if (get_request_param('purgedata', 'false') === 'true') {
        $GLOBALS['m3client']->metricsPurgeApiDurations();
    }
    echo <<<EOF
    <form action="metrics.php?show=apidurations" method="get">
       <input type="submit" value="Clear Data" />
       <input type="hidden" name="show" value="apidurations" />
       <input type="hidden" name="purgedata" value="true" />
    </form>
EOF;
    // $_metrics[API] = array("count", "min", "max", "avg")
    $_metrics = $GLOBALS['m3client']->metricsGetApiDurations();
    echo <<<EOF
    <table border="1">
    <tr>
        <th>API</td>
        <th>Invocation Count</th>
        <th>Min Time(ms)</th>
        <th>Max Time(ms)</th>
        <th>Average Time(ms)</th>
    </tr>
EOF;
    foreach ($_metrics as $_apiName => $_stats) {
        $_count = $_stats['count'];
        $_min = sprintf("%5.2f", 1000 * $_stats['min']);
        $_max = sprintf("%5.2f", 1000 * $_stats['max']);
        $_avg = sprintf("%5.2f", 1000 * $_stats['avg']);
        echo <<<EOF2
    <tr>
        <td>{$_apiName}</td>
        <td>{$_count}</td>
        <td>{$_min}</td>
        <td>{$_max}</td>
        <td>{$_avg}</td>
    </tr>
EOF2;
    }
    echo "</table>\n";
    echo_api_visualization($_metrics);
}
Example #5
0
function rx_interceptor_template($user, $info, $handlerName)
{
    $user->validate();
    include_once RUDRA . "/core/handler/AbstractHandler.php";
    $handlerInfo = ClassUtil::getHandler($handlerName);
    if ($handlerInfo != NULL) {
        global $temp;
        include_once $handlerInfo["filePath"];
        $className = $handlerInfo["className"];
        $tempClass = new ReflectionClass($className);
        if ($tempClass->isInstantiable()) {
            $temp = $tempClass->newInstance();
        }
        if ($temp != NULL) {
            if ($tempClass->hasMethod("invokeHandler")) {
                $tpl = new Smarty();
                call_user_func(rx_function("rx_set_smarty_paths"), $tpl);
                $tpl->debugging = RX_SMARTY_DEBUG;
                $page = new Page();
                $view = call_method_by_class($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'page' => $page, 'dataModel' => $page->data, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]);
                if (!isset($view)) {
                    $view = $handlerName;
                }
                $tpl->assign('user', $user);
                $tpl->assign('CONTEXT_PATH', CONTEXT_PATH);
                $tpl->assign('RESOURCE_PATH', RESOURCE_PATH);
                if (isset($tpl->repeatData)) {
                    foreach ($tpl->repeatData as $key => $value) {
                        $tpl->assign($value['key'], $value['value']);
                        $tpl->display($this->getViewPath() . $view . Config::get('TEMP_EXT'));
                    }
                } else {
                    $tpl->display($this->getViewPath() . $view . Config::get('TEMP_EXT'));
                }
                echo TEMP_DELIMITER;
                Browser::printlogs();
                echo TEMP_DELIMITER . json_encode($page->data->data);
                Browser::printlogs();
            }
        }
    }
}
Example #6
0
function get_argument_array($reflectionMethod, $argArray, $from_request = TRUE, $skipEmpty = FALSE)
{
    $arr = array();
    foreach ($reflectionMethod->getParameters() as $key => $val) {
        if (isset($argArray[$val->getName()]) && !($skipEmpty && empty($argArray[$val->getName()]))) {
            $arr[$val->getName()] = $argArray[$val->getName()];
        } else {
            if ($from_request && !is_null(get_request_param($val->getName(), $skipEmpty))) {
                $arr[$val->getName()] = get_request_param($val->getName());
            } else {
                if ($val->isDefaultValueAvailable()) {
                    $arr[$val->getName()] = $val->getDefaultValue();
                } else {
                    $arr[$val->getName()] = NULL;
                }
            }
        }
    }
    return $arr;
}
Example #7
0
                 selected='<?php 
echo get_request_param('show', 'localsettings') === 'localsettings' ? 'true' : '';
?>
' />
    <fb:tab-item href='config.php?show=phpini'
                 title='php.ini'
                 selected='<?php 
echo get_request_param('show') === 'phpini' ? 'true' : '';
?>
' />
    <fb:tab-item href='config.php?show=phpinfo'
                 title='PHP Info'
                 selected='<?php 
echo get_request_param('show') === 'phpinfo' ? 'true' : '';
?>
' />
</fb:tabs>
<?php 
if (get_request_param('show', 'localsettings') === 'localsettings') {
    echo_localsettings();
} else {
    if (get_request_param('show') === 'phpini') {
        echo_php_ini();
    } else {
        if (get_request_param('show') === 'phpinfo') {
            echo_php_info();
        } else {
            echo_localsettings();
        }
    }
}
Example #8
0
function getCurrentNumOfGoods()
{
    $query = "SELECT count(*) from goods WHERE cathegory_id=" . get_request_param('category') . ' ' . setWhere();
    $cnt_array = get_data($query);
    return $cnt_array[0]['count(*)'];
}
Example #9
0
    <fb:tab-item href='inventory.php?show=tags'
                 title='Tags'
                 selected='<?php 
echo get_request_param('show') === 'tags' ? 'true' : '';
?>
' />
    <fb:tab-item href='inventory.php?show=domains'
                 title='Domains'
                 selected='<?php 
echo get_request_param('show') === 'domains' ? 'true' : '';
?>
' />
</fb:tabs>
<?php 
if (get_request_param('show', 'api') === 'api') {
    echo_api_inventory();
} else {
    if (get_request_param('show') === 'applications') {
        echo_app_inventory();
    } else {
        if (get_request_param('show') === 'tags') {
            echo_tag_inventory();
        } else {
            if (get_request_param('show') === 'domains') {
                echo_domain_inventory();
            } else {
                echo_api_inventory();
            }
        }
    }
}