예제 #1
0
function main_editprofile($eventData)
{
    global $env, $amp_locale, $hui_mainframe, $hui_titlebar, $gEnv;
    $prof_query =& $env['ampdb']->execute('SELECT * ' . 'FROM xmlrpcprofiles ' . 'WHERE id=' . $eventData['profileid']);
    $prof_data = $prof_query->Fields();
    $methods_query =& $env['ampdb']->Execute('SELECT module,name,unsecure,catalog ' . 'FROM xmlrpcmethods ' . 'ORDER BY module, name');
    if ($methods_query->NumRows()) {
        $nodes = $sec = $desc = array();
        $prev_catalog = $tmp_locale = '';
        while (!$methods_query->eof) {
            $nodes[$methods_query->Fields('module')][] = $methods_query->Fields('name');
            $sec[$methods_query->Fields('module')][$methods_query->Fields('name')] = $methods_query->Fields('unsecure') == $env['ampdb']->fmttrue ? false : true;
            $tmp_description = '';
            if (strlen($methods_query->Fields('catalog'))) {
                if ($prev_catalog != $methods_query->Fields('catalog')) {
                    $tmp_locale = new Locale($methods_query->Fields('catalog'), $gEnv['root']['locale']['language']);
                }
                $desc[$methods_query->Fields('module')][$methods_query->Fields('name')] = $tmp_locale->GetStr($methods_query->Fields('name'));
                $prev_catalog = $methods_query->Fields('catalog');
            }
            $methods_query->MoveNext();
        }
        $row = 0;
        $headers[0]['label'] = '';
        $headers[1]['label'] = $amp_locale->GetStr('xmlrpcmodule_header');
        $headers[2]['label'] = '';
        $headers[3]['label'] = $amp_locale->GetStr('xmlrpcmethod_header');
        $headers[4]['label'] = $amp_locale->GetStr('docstring_header');
        $headers[5]['label'] = $amp_locale->GetStr('security_header');
        $hui_methods_table = new HuiTable('methodstable', array('headers' => $headers, 'rowsperpage' => '15', 'pagesactionfunction' => 'editprofile_list_action_builder', 'pagenumber' => $eventData['editprofilepage'], 'sessionobjectusername' => $eventData['profileid']));
        while (list($module, $methods) = each($nodes)) {
            $xprofile = new XmlRpcProfile($env['ampdb'], $eventData['profileid']);
            $node_state = $xprofile->NodeCheck(XMLRPCPROFILE_NODETYPE_MODULE, $module);
            switch ($node_state) {
                case XMLRPCPROFILE_MODULENODE_FULLYENABLED:
                    $icon = $hui_mainframe->mThemeHandler->mStyle['greenball'];
                    $enabled = true;
                    break;
                case XMLRPCPROFILE_MODULENODE_PARTIALLYENABLED:
                    $icon = $hui_mainframe->mThemeHandler->mStyle['goldball'];
                    $enabled = true;
                    break;
                case XMLRPCPROFILE_MODULENODE_NOTENABLED:
                    $icon = $hui_mainframe->mThemeHandler->mStyle['redball'];
                    $enabled = false;
                    break;
            }
            $hui_methods_table->AddChild(new HuiImage('statusimage' . $row, array('imageurl' => $icon)), $row, 0);
            $hui_methods_table->AddChild(new HuiLabel('modulelabel' . $row, array('label' => $module)), $row, 1);
            $hui_module_toolbar[$row] = new HuiToolBar('moduletoolbar' . $row);
            if ($enabled) {
                $disable_action[$row] = new HuiEventsCall();
                $disable_action[$row]->AddEvent(new HuiEvent('main', 'editprofile', array('profileid' => $eventData['profileid'])));
                $disable_action[$row]->AddEvent(new HuiEvent('pass', 'disablenode', array('nodetype' => XMLRPCPROFILE_NODETYPE_MODULE, 'module' => $module, 'profileid' => $eventData['profileid'])));
                $hui_disable_button[$row] = new HuiButton('disablebutton' . $row, array(label => $amp_locale->GetStr('disablenode_label'), 'horiz' => 'true', 'themeimage' => 'lock', 'action' => $disable_action[$row]->GetEventsCallString()));
                $hui_module_toolbar[$row]->AddChild($hui_disable_button[$row]);
            }
            if (!$enabled or $node_state == XMLRPCPROFILE_MODULENODE_PARTIALLYENABLED) {
                $enable_action[$row] = new HuiEventsCall();
                $enable_action[$row]->AddEvent(new HuiEvent('main', 'editprofile', array('profileid' => $eventData['profileid'])));
                $enable_action[$row]->AddEvent(new HuiEvent('pass', 'enablenode', array('nodetype' => XMLRPCPROFILE_NODETYPE_MODULE, 'module' => $module, 'profileid' => $eventData['profileid'])));
                $hui_enable_button[$row] = new HuiButton('enablebutton' . $row, array(label => $amp_locale->GetStr('enablenode_label'), 'horiz' => 'true', 'themeimage' => 'unlock', 'action' => $enable_action[$row]->GetEventsCallString()));
                $hui_module_toolbar[$row]->AddChild($hui_enable_button[$row]);
            }
            $hui_methods_table->AddChild($hui_module_toolbar[$row], $row, 6);
            $row++;
            while (list(, $method) = each($methods)) {
                $node_state = $xprofile->NodeCheck(XMLRPCPROFILE_NODETYPE_METHOD, $module, $method);
                switch ($node_state) {
                    case XMLRPCPROFILE_METHODNODE_ENABLED:
                        $icon = $hui_mainframe->mThemeHandler->mStyle['greenball'];
                        $enabled = true;
                        break;
                    case XMLRPCPROFILE_METHODNODE_NOTENABLED:
                        $icon = $hui_mainframe->mThemeHandler->mStyle['redball'];
                        $enabled = false;
                        break;
                }
                $hui_methods_table->AddChild(new HuiImage('statusimage' . $row, array('imageurl' => $icon)), $row, 2);
                $hui_methods_table->AddChild(new HuiLabel('methodlabel' . $row, array('label' => $method)), $row, 3);
                $img = $sec[$module][$method] == true ? 'button_ok' : 'button_cancel';
                $secure_image = $hui_methods_table->mThemeHandler->mIconsBase . $hui_methods_table->mThemeHandler->mIconsSet['actions'][$img]['base'] . '/actions/' . $hui_methods_table->mThemeHandler->mIconsSet['actions'][$img]['file'];
                $hui_methods_table->AddChild(new HuiLabel('desclabel' . $row, array('label' => $desc[$module][$method])), $row, 4);
                $hui_methods_table->AddChild(new HuiImage('secure' . $row, array('imageurl' => $secure_image)), $row, 5);
                $hui_method_toolbar[$row] = new HuiToolBar('methodtoolbar' . $row);
                if ($enabled) {
                    $disable_action[$row] = new HuiEventsCall();
                    $disable_action[$row]->AddEvent(new HuiEvent('main', 'editprofile', array('profileid' => $eventData['profileid'])));
                    $disable_action[$row]->AddEvent(new HuiEvent('pass', 'disablenode', array('nodetype' => XMLRPCPROFILE_NODETYPE_METHOD, 'method' => $method, 'module' => $module, 'profileid' => $eventData['profileid'])));
                    $hui_disable_button[$row] = new HuiButton('disablebutton' . $row, array(label => $amp_locale->GetStr('disablenode_label'), 'horiz' => 'true', 'themeimage' => 'lock', 'action' => $disable_action[$row]->GetEventsCallString()));
                    $hui_method_toolbar[$row]->AddChild($hui_disable_button[$row]);
                } else {
                    $enable_action[$row] = new HuiEventsCall();
                    $enable_action[$row]->AddEvent(new HuiEvent('main', 'editprofile', array('profileid' => $eventData['profileid'])));
                    $enable_action[$row]->AddEvent(new HuiEvent('pass', 'enablenode', array('nodetype' => XMLRPCPROFILE_NODETYPE_METHOD, 'method' => $method, 'module' => $module, 'profileid' => $eventData['profileid'])));
                    $hui_enable_button[$row] = new HuiButton('enablebutton' . $row, array(label => $amp_locale->GetStr('enablenode_label'), 'horiz' => 'true', 'themeimage' => 'unlock', 'action' => $enable_action[$row]->GetEventsCallString()));
                    $hui_method_toolbar[$row]->AddChild($hui_enable_button[$row]);
                }
                $hui_methods_table->AddChild($hui_method_toolbar[$row], $row, 6);
                $row++;
            }
        }
        $hui_mainframe->AddChild($hui_methods_table);
    }
    $hui_titlebar->mTitle .= ' - ' . $prof_data['profilename'] . ' - ' . $amp_locale->GetStr('editprofile_title');
}
예제 #2
0
    define('AMPREMOTE_PHP', true);
    require 'ampoliros.php';
    $amp = Ampoliros::instance('Ampoliros');
    $amp->setMode(Ampoliros::MODE_ROOT);
    $amp->setInterface(Ampoliros::INTERFACE_REMOTE);
    OpenLibrary('xmlrpc.library');
    OpenLibrary('misc.library');
    $env['db'] = $GLOBALS['gEnv']['root']['db'];
    $GLOBALS['gEnv']['remote']['methods'] = array();
    $xuser = new XmlRpcUser($GLOBALS['gEnv']['root']['db']);
    if ($xuser->SetByAccount($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
        $GLOBALS['gEnv']['remote']['user'] = $_SERVER['PHP_AUTH_USER'];
        $GLOBALS['gEnv']['remote']['profile'] = $xuser->mProfileId;
        if ($xuser->mSiteId) {
            $site_query = $GLOBALS['gEnv']['root']['db']->Execute('SELECT siteid FROM sites WHERE id=' . $xuser->mSiteId);
            if ($site_query->NumRows()) {
                $amp = Ampoliros::instance('Ampoliros');
                $amp->startSite($site_query->Fields('siteid'));
            }
        }
        $xprofile = new XmlRpcProfile($GLOBALS['gEnv']['root']['db'], $GLOBALS['gEnv']['remote']['profile']);
        $GLOBALS['gEnv']['remote']['methods'] = $xprofile->AvailableMethods();
    } else {
        if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_WRONG_REMOTE_LOGIN') == '1') {
            import('com.solarix.ampoliros.security.SecurityLayer');
            $amp_security = new SecurityLayer();
            $amp_security->SendAlert('Wrong remote login for user ' . $_SERVER['PHP_AUTH_USER'] . ' from remote address ' . $_SERVER['REMOTE_ADDR']);
            unset($amp_security);
        }
    }
}