コード例 #1
0
 public static function IsEnabled()
 {
     if (self::$m_bEnabled_Duration || self::$m_bEnabled_Memory) {
         if (self::$m_sAllowedUser == '*' || UserRights::GetUser() == trim(self::$m_sAllowedUser)) {
             return true;
         }
     }
     return false;
 }
コード例 #2
0
 public function DoExecute($oTrigger, $aContextArgs)
 {
     if (MetaModel::IsLogEnabledNotification()) {
         $oLog = new EventNotificationShellExec();
         if ($this->IsBeingTested()) {
             $oLog->Set('message', 'TEST - Executing script (' . $this->Get('script_path') . ')');
         } else {
             $oLog->Set('message', 'Executing script');
         }
         $oLog->Set('userinfo', UserRights::GetUser());
         $oLog->Set('trigger_id', $oTrigger->GetKey());
         $oLog->Set('action_id', $this->GetKey());
         $oLog->Set('object_id', $aContextArgs['this->object()']->GetKey());
         // Must be inserted now so that it gets a valid id that will make the link
         // between an eventual asynchronous task (queued) and the log
         $oLog->DBInsertNoReload();
     } else {
         $oLog = null;
     }
     try {
         $sRes = $this->_DoExecute($oTrigger, $aContextArgs, $oLog);
         if ($this->IsBeingTested()) {
             $sPrefix = 'TEST (' . $this->Get('script_path') . ') - ';
         } else {
             $sPrefix = '';
         }
         $oLog->Set('message', $sPrefix . $sRes);
     } catch (Exception $e) {
         if ($oLog) {
             $oLog->Set('message', 'Error: ' . $e->getMessage());
         }
     }
     if ($oLog) {
         $oLog->DBUpdate();
     }
 }
コード例 #3
0
 /**
  * Attempt a login
  * 	 	
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  * @return int One of the class constants EXIT_CODE_...
  */
 protected static function Login($iOnExit)
 {
     if (self::SecureConnectionRequired() && !utils::IsConnectionSecure()) {
         // Non secured URL... request for a secure connection
         throw new Exception('Secure connection required!');
     }
     $aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
     if (isset($_SESSION['auth_user'])) {
         //echo "User: "******"\n";
         // Already authentified
         UserRights::Login($_SESSION['auth_user']);
         // Login & set the user's language
         return self::EXIT_CODE_OK;
     } else {
         $index = 0;
         $sLoginMode = '';
         $sAuthentication = 'internal';
         while ($sLoginMode == '' && $index < count($aAllowedLoginTypes)) {
             $sLoginType = $aAllowedLoginTypes[$index];
             switch ($sLoginType) {
                 case 'cas':
                     utils::InitCASClient();
                     // check CAS authentication
                     if (phpCAS::isAuthenticated()) {
                         $sAuthUser = phpCAS::getUser();
                         $sAuthPwd = '';
                         $sLoginMode = 'cas';
                         $sAuthentication = 'external';
                     }
                     break;
                 case 'form':
                     // iTop standard mode: form based authentication
                     $sAuthUser = utils::ReadPostedParam('auth_user', '', false, 'raw_data');
                     $sAuthPwd = utils::ReadPostedParam('auth_pwd', null, false, 'raw_data');
                     if ($sAuthUser != '' && $sAuthPwd !== null) {
                         $sLoginMode = 'form';
                     }
                     break;
                 case 'basic':
                     // Standard PHP authentication method, works with Apache...
                     // Case 1) Apache running in CGI mode + rewrite rules in .htaccess
                     if (isset($_SERVER['HTTP_AUTHORIZATION']) && !empty($_SERVER['HTTP_AUTHORIZATION'])) {
                         list($sAuthUser, $sAuthPwd) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
                         $sLoginMode = 'basic';
                     } else {
                         if (isset($_SERVER['PHP_AUTH_USER'])) {
                             $sAuthUser = $_SERVER['PHP_AUTH_USER'];
                             // Unfortunately, the RFC is not clear about the encoding...
                             // IE and FF supply the user and password encoded in ISO-8859-1 whereas Chrome provides them encoded in UTF-8
                             // So let's try to guess if it's an UTF-8 string or not... fortunately all encodings share the same ASCII base
                             if (!self::LooksLikeUTF8($sAuthUser)) {
                                 // Does not look like and UTF-8 string, try to convert it from iso-8859-1 to UTF-8
                                 // Supposed to be harmless in case of a plain ASCII string...
                                 $sAuthUser = iconv('iso-8859-1', 'utf-8', $sAuthUser);
                             }
                             $sAuthPwd = $_SERVER['PHP_AUTH_PW'];
                             if (!self::LooksLikeUTF8($sAuthPwd)) {
                                 // Does not look like and UTF-8 string, try to convert it from iso-8859-1 to UTF-8
                                 // Supposed to be harmless in case of a plain ASCII string...
                                 $sAuthPwd = iconv('iso-8859-1', 'utf-8', $sAuthPwd);
                             }
                             $sLoginMode = 'basic';
                         }
                     }
                     break;
                 case 'external':
                     // Web server supplied authentication
                     $bExternalAuth = false;
                     $sExtAuthVar = MetaModel::GetConfig()->GetExternalAuthenticationVariable();
                     // In which variable is the info passed ?
                     eval('$sAuthUser = isset(' . $sExtAuthVar . ') ? ' . $sExtAuthVar . ' : false;');
                     // Retrieve the value
                     if ($sAuthUser && strlen($sAuthUser) > 0) {
                         $sAuthPwd = '';
                         // No password in this case the web server already authentified the user...
                         $sLoginMode = 'external';
                         $sAuthentication = 'external';
                     }
                     break;
                 case 'url':
                     // Credentials passed directly in the url
                     $sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
                     $sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
                     if ($sAuthUser != '' && $sAuthPwd !== null) {
                         $sLoginMode = 'url';
                     }
                     break;
             }
             $index++;
         }
         //echo "\nsLoginMode: $sLoginMode (user: $sAuthUser / pwd: $sAuthPwd\n)";
         if ($sLoginMode == '') {
             // First connection
             $sDesiredLoginMode = utils::ReadParam('login_mode');
             if (in_array($sDesiredLoginMode, $aAllowedLoginTypes)) {
                 $sLoginMode = $sDesiredLoginMode;
             } else {
                 $sLoginMode = $aAllowedLoginTypes[0];
                 // First in the list...
             }
             if (array_key_exists('HTTP_X_COMBODO_AJAX', $_SERVER)) {
                 // X-Combodo-Ajax is a special header automatically added to all ajax requests
                 // Let's reply that we're currently logged-out
                 header('HTTP/1.0 401 Unauthorized');
                 exit;
             }
             if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
                 header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
                 header('HTTP/1.0 401 Unauthorized');
                 header('Content-type: text/html; charset=iso-8859-1');
                 exit;
             } else {
                 if ($iOnExit == self::EXIT_RETURN) {
                     if ($sAuthUser !== '' && $sAuthPwd === null) {
                         return self::EXIT_CODE_MISSINGPASSWORD;
                     } else {
                         return self::EXIT_CODE_MISSINGLOGIN;
                     }
                 } else {
                     $oPage = self::NewLoginWebPage();
                     $oPage->DisplayLoginForm($sLoginMode, false);
                     $oPage->output();
                     exit;
                 }
             }
         } else {
             if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $sLoginMode, $sAuthentication)) {
                 //echo "Check Credentials returned false for user $sAuthUser!";
                 self::ResetSession();
                 if ($iOnExit == self::EXIT_HTTP_401 || $sLoginMode == 'basic') {
                     header('WWW-Authenticate: Basic realm="' . Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
                     header('HTTP/1.0 401 Unauthorized');
                     header('Content-type: text/html; charset=iso-8859-1');
                     exit;
                 } else {
                     if ($iOnExit == self::EXIT_RETURN) {
                         return self::EXIT_CODE_WRONGCREDENTIALS;
                     } else {
                         $oPage = self::NewLoginWebPage();
                         $oPage->DisplayLoginForm($sLoginMode, true);
                         $oPage->output();
                         exit;
                     }
                 }
             } else {
                 // User is Ok, let's save it in the session and proceed with normal login
                 UserRights::Login($sAuthUser, $sAuthentication);
                 // Login & set the user's language
                 if (MetaModel::GetConfig()->Get('log_usage')) {
                     $oLog = new EventLoginUsage();
                     $oLog->Set('userinfo', UserRights::GetUser());
                     $oLog->Set('user_id', UserRights::GetUserObject()->GetKey());
                     $oLog->Set('message', 'Successful login');
                     $oLog->DBInsertNoReload();
                 }
                 $_SESSION['auth_user'] = $sAuthUser;
                 $_SESSION['login_mode'] = $sLoginMode;
                 UserRights::_InitSessionCache();
             }
         }
     }
     return self::EXIT_CODE_OK;
 }
コード例 #4
0
 /**
  * Helper to log a service delivery
  *
  * @param string sVerb
  * @param array aArgs
  * @param WebServiceResult oRes
  *
  */
 protected function LogUsage($sVerb, $oRes)
 {
     if (!MetaModel::IsLogEnabledWebService()) {
         return;
     }
     $oLog = new EventWebService();
     if ($oRes->IsOk()) {
         $oLog->Set('message', $sVerb . ' was successfully invoked');
     } else {
         $oLog->Set('message', $sVerb . ' returned errors');
     }
     $oLog->Set('userinfo', UserRights::GetUser());
     $oLog->Set('verb', $sVerb);
     $oLog->Set('result', $oRes->IsOk());
     $this->TrimAndSetValue($oLog, 'log_info', (string) $oRes->GetInfoAsText());
     $this->TrimAndSetValue($oLog, 'log_warning', (string) $oRes->GetWarningsAsText());
     $this->TrimAndSetValue($oLog, 'log_error', (string) $oRes->GetErrorsAsText());
     $this->TrimAndSetValue($oLog, 'data', (string) $oRes->GetReturnedDataAsText());
     $oLog->DBInsertNoReload();
 }
コード例 #5
0
 protected static function GetUserPrefix()
 {
     $sPrefix = substr(UserRights::GetUser(), 0, 10);
     $sPrefix = preg_replace('/[^a-zA-Z0-9-_]/', '_', $sPrefix);
     return $sPrefix . '-';
 }
コード例 #6
0
    /**
     * Outputs (via some echo) the complete HTML page by assembling all its elements
     */
    public function output()
    {
        $sAbsURLAppRoot = addslashes($this->m_sRootUrl);
        //$this->set_base($this->m_sRootUrl.'pages/');
        $sForm = $this->GetSiloSelectionForm();
        $this->DisplayMenu();
        // Compute the menu
        // Call the extensions to add content to the page, so that they can also add styles or scripts
        $sBannerExtraHtml = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sBannerExtraHtml .= $oExtensionInstance->GetBannerHtml($this);
        }
        $sNorthPane = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sNorthPane .= $oExtensionInstance->GetNorthPaneHtml($this);
        }
        if (UserRights::IsAdministrator() && ExecutionKPI::IsEnabled()) {
            $sNorthPane .= '<div id="admin-banner"><span style="padding:5px;">' . ExecutionKPI::GetDescription() . '<span></div>';
        }
        //$sSouthPane = '<p>Peak memory Usage: '.sprintf('%.3f MB', memory_get_peak_usage(true) / (1024*1024)).'</p>';
        $sSouthPane = '';
        foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) {
            $sSouthPane .= $oExtensionInstance->GetSouthPaneHtml($this);
        }
        // Put here the 'ready scripts' that must be executed after all others
        $aMultiselectOptions = array('header' => true, 'checkAllText' => Dict::S('UI:SearchValue:CheckAll'), 'uncheckAllText' => Dict::S('UI:SearchValue:UncheckAll'), 'noneSelectedText' => Dict::S('UI:SearchValue:Any'), 'selectedText' => Dict::S('UI:SearchValue:NbSelected'), 'selectedList' => 1);
        $sJSMultiselectOptions = json_encode($aMultiselectOptions);
        $this->add_ready_script(<<<EOF
\t\t// Since the event is only triggered when the hash changes, we need to trigger
\t\t// the event now, to handle the hash the page may have loaded with.
\t\t\$(window).trigger( 'hashchange' );
\t\t
\t\t// Some table are sort-able, some are not, let's fix this
\t\t\$('table.listResults').each( function() { FixTableSorter(\$(this)); } );
\t\t
\t\t\$('.multiselect').multiselect({$sJSMultiselectOptions});

\t\tFixSearchFormsDisposition();

EOF
);
        if ($this->GetOutputFormat() == 'html') {
            foreach ($this->a_headers as $s_header) {
                header($s_header);
            }
        }
        $s_captured_output = $this->ob_get_clean_safe();
        $sHtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
        $sHtml .= "<html>\n";
        $sHtml .= "<head>\n";
        // Make sure that Internet Explorer renders the page using its latest/highest/greatest standards !
        $sHtml .= "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n";
        $sHtml .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
        $sHtml .= "<title>" . htmlentities($this->s_title, ENT_QUOTES, 'UTF-8') . "</title>\n";
        $sHtml .= $this->get_base_tag();
        // Stylesheets MUST be loaded before any scripts otherwise
        // jQuery scripts may face some spurious problems (like failing on a 'reload')
        foreach ($this->a_linked_stylesheets as $a_stylesheet) {
            if ($a_stylesheet['condition'] != "") {
                $sHtml .= "<!--[if {$a_stylesheet['condition']}]>\n";
            }
            $sHtml .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$a_stylesheet['link']}\" />\n";
            if ($a_stylesheet['condition'] != "") {
                $sHtml .= "<![endif]-->\n";
            }
        }
        // special stylesheet for printing, hides the navigation gadgets
        $sHtml .= "<link rel=\"stylesheet\" media=\"print\" type=\"text/css\" href=\"../css/print.css\" />\n";
        if ($this->GetOutputFormat() == 'html') {
            $sHtml .= $this->output_dict_entries(true);
            // before any script so that they can benefit from the translations
            foreach ($this->a_linked_scripts as $s_script) {
                // Make sure that the URL to the script contains the application's version number
                // so that the new script do NOT get reloaded from the cache when the application is upgraded
                if (strpos($s_script, '?') === false) {
                    $s_script .= "?itopversion=" . ITOP_VERSION;
                } else {
                    $s_script .= "&itopversion=" . ITOP_VERSION;
                }
                $sHtml .= "<script type=\"text/javascript\" src=\"{$s_script}\"></script>\n";
            }
            $this->add_script("var iPaneVisWatchDog  = window.setTimeout('FixPaneVis()',5000);\n\$(document).ready(function() {\n{$this->m_sInitScript};\nwindow.setTimeout('onDelayedReady()',10)\n});");
            if (count($this->m_aReadyScripts) > 0) {
                $this->add_script("\nonDelayedReady = function() {\n" . implode("\n", $this->m_aReadyScripts) . "\n}\n");
            }
            if (count($this->a_scripts) > 0) {
                $sHtml .= "<script type=\"text/javascript\">\n";
                foreach ($this->a_scripts as $s_script) {
                    $sHtml .= "{$s_script}\n";
                }
                $sHtml .= "</script>\n";
            }
        }
        if (count($this->a_styles) > 0) {
            $sHtml .= "<style>\n";
            foreach ($this->a_styles as $s_style) {
                $sHtml .= "{$s_style}\n";
            }
            $sHtml .= "</style>\n";
        }
        $sHtml .= "<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"iTop\" href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/opensearch.xml.php\" />\n";
        $sHtml .= "<link rel=\"shortcut icon\" href=\"" . utils::GetAbsoluteUrlAppRoot() . "images/favicon.ico\" />\n";
        $sHtml .= "</head>\n";
        $sHtml .= "<body>\n";
        // Render the revision number
        if (ITOP_REVISION == '$WCREV$') {
            // This is NOT a version built using the buil system, just display the main version
            $sVersionString = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
        } else {
            // This is a build made from SVN, let display the full information
            $sVersionString = Dict::Format('UI:iTopVersion:Long', ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
        }
        // Render the text of the global search form
        $sText = htmlentities(utils::ReadParam('text', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8');
        $sOnClick = "";
        if (empty($sText)) {
            // if no search text is supplied then
            // 1) the search text is filled with "your search"
            // 2) clicking on it will erase it
            $sText = Dict::S("UI:YourSearch");
            $sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
        }
        // Render the tabs in the page (if any)
        $this->s_content = $this->m_oTabs->RenderIntoContent($this->s_content);
        if ($this->GetOutputFormat() == 'html') {
            $oAppContext = new ApplicationContext();
            $sUserName = UserRights::GetUser();
            $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
            if (UserRights::IsAdministrator()) {
                $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
            } else {
                $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
            }
            $sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
            $sLogOffMenu .= "<li><span>{$sLogonMessage}</span></li>\n";
            $aActions = array();
            $oPrefs = new URLPopupMenuItem('UI:Preferences', Dict::S('UI:Preferences'), utils::GetAbsoluteUrlAppRoot() . "pages/preferences.php?" . $oAppContext->GetForLink());
            $aActions[$oPrefs->GetUID()] = $oPrefs->GetMenuItem();
            if (utils::CanLogOff()) {
                $oLogOff = new URLPopupMenuItem('UI:LogOffMenu', Dict::S('UI:LogOffMenu'), utils::GetAbsoluteUrlAppRoot() . 'pages/logoff.php?operation=do_logoff');
                $aActions[$oLogOff->GetUID()] = $oLogOff->GetMenuItem();
            }
            if (UserRights::CanChangePassword()) {
                $oChangePwd = new URLPopupMenuItem('UI:ChangePwdMenu', Dict::S('UI:ChangePwdMenu'), utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?loginop=change_pwd');
                $aActions[$oChangePwd->GetUID()] = $oChangePwd->GetMenuItem();
            }
            utils::GetPopupMenuItems($this, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aActions);
            $oAbout = new JSPopupMenuItem('UI:AboutBox', Dict::S('UI:AboutBox'), 'return ShowAboutBox();');
            $aActions[$oAbout->GetUID()] = $oAbout->GetMenuItem();
            $sLogOffMenu .= $this->RenderPopupMenuItems($aActions);
            $sRestrictions = '';
            if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) {
                if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) {
                    $sRestrictions = Dict::S('UI:AccessRO-All');
                }
            } elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) {
                $sRestrictions = Dict::S('UI:AccessRO-Users');
            }
            $sApplicationBanner = '';
            if (strlen($sRestrictions) > 0) {
                $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message'));
                $sApplicationBanner .= '<div id="admin-banner">';
                $sApplicationBanner .= '<img src="../images/locked.png" style="vertical-align:middle;">';
                $sApplicationBanner .= '&nbsp;<b>' . $sRestrictions . '</b>';
                if (strlen($sAdminMessage) > 0) {
                    $sApplicationBanner .= '&nbsp;<b>' . $sAdminMessage . '</b>';
                }
                $sApplicationBanner .= '</div>';
            }
            if (strlen($this->m_sMessage)) {
                $sApplicationBanner .= '<div id="admin-banner"><span style="padding:5px;">' . $this->m_sMessage . '<span></div>';
            }
            $sApplicationBanner .= $sBannerExtraHtml;
            if (!empty($sNorthPane)) {
                $sNorthPane = '<div id="bottom-pane" class="ui-layout-north">' . $sNorthPane . '</div>';
            }
            if (!empty($sSouthPane)) {
                $sSouthPane = '<div id="bottom-pane" class="ui-layout-south">' . $sSouthPane . '</div>';
            }
            $sIconUrl = Utils::GetConfig()->Get('app_icon_url');
            $sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help');
            //$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
            $sDisplayIcon = utils::GetAbsoluteUrlAppRoot() . 'images/itop-logo.png';
            if (file_exists(MODULESROOT . 'branding/main-logo.png')) {
                $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot() . 'branding/main-logo.png';
            }
            $sHtml .= $sNorthPane;
            $sHtml .= '<div id="left-pane" class="ui-layout-west">';
            $sHtml .= '<!-- Beginning of the left pane -->';
            $sHtml .= ' <div class="ui-layout-north">';
            $sHtml .= ' <div id="header-logo">';
            $sHtml .= ' <div id="top-left"></div><div id="logo"><a href="' . htmlentities($sIconUrl, ENT_QUOTES, 'UTF-8') . '"><img src="' . $sDisplayIcon . '" title="' . htmlentities($sVersionString, ENT_QUOTES, 'UTF-8') . '" style="border:0; margin-top:16px; margin-right:40px;"/></a></div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div class="header-menu">';
            if (!MetaModel::GetConfig()->Get('demo_mode')) {
                $sHtml .= '		<div class="icon ui-state-default ui-corner-all"><span id="tPinMenu" class="ui-icon ui-icon-pin-w">pin</span></div>';
            }
            $sHtml .= '		<div style="text-align:center;">' . self::FilterXSS($sForm) . '</div>';
            $sHtml .= ' </div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div id="menu" class="ui-layout-center">';
            $sHtml .= '		<div id="inner_menu">';
            $sHtml .= '			<div id="accordion">';
            $sHtml .= self::FilterXSS($this->m_sMenu);
            $sHtml .= '			<!-- Beginning of the accordion menu -->';
            $sHtml .= '			<!-- End of the accordion menu-->';
            $sHtml .= '			</div>';
            $sHtml .= '		</div> <!-- /inner menu -->';
            $sHtml .= ' </div> <!-- /menu -->';
            $sHtml .= ' <div class="footer ui-layout-south"><div id="combodo_logo"><a href="http://www.combodo.com" title="www.combodo.com" target="_blank"><img src="../images/logo-combodo.png"/></a></div></div>';
            $sHtml .= '<!-- End of the left pane -->';
            $sHtml .= '</div>';
            $sHtml .= '<div class="ui-layout-center">';
            $sHtml .= ' <div id="top-bar" style="width:100%">';
            $sHtml .= self::FilterXSS($sApplicationBanner);
            $sHtml .= '		<div id="global-search"><form action="' . utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php"><table><tr><td></td><td id="g-search-input"><input type="text" name="text" value="' . $sText . '"' . $sOnClick . '/></td>';
            $sHtml .= '<td><input type="image" src="../images/searchBtn.png"/></a></td>';
            $sHtml .= '<td><a style="background:transparent;" href="' . $sOnlineHelpUrl . '" target="_blank"><img style="border:0;padding-left:20px;padding-right:10px;" title="' . Dict::S('UI:Help') . '" src="../images/help.png"/></td>';
            $sHtml .= '<td style="padding-right:20px;padding-left:10px;">' . self::FilterXSS($sLogOffMenu) . '</td><td><input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
            //echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
            $sHtml .= ' </div>';
            $sHtml .= ' <div class="ui-layout-content" style="overflow:auto;">';
            $sHtml .= ' <!-- Beginning of page content -->';
            $sHtml .= self::FilterXSS($this->s_content);
            $sHtml .= ' <!-- End of page content -->';
            $sHtml .= ' </div>';
            $sHtml .= '</div>';
            $sHtml .= $sSouthPane;
            // Add the captured output
            if (trim($s_captured_output) != "") {
                $sHtml .= "<div id=\"rawOutput\" title=\"Debug Output\"><div style=\"height:500px; overflow-y:auto;\">" . self::FilterXSS($s_captured_output) . "</div></div>\n";
            }
            $sHtml .= "<div id=\"at_the_end\">" . self::FilterXSS($this->s_deferred_content) . "</div>";
            $sHtml .= "<div style=\"display:none\" title=\"ex2\" id=\"ex2\">Please wait...</div>\n";
            // jqModal Window
            $sHtml .= "<div style=\"display:none\" title=\"dialog\" id=\"ModalDlg\"></div>";
            $sHtml .= "<div style=\"display:none\" id=\"ajax_content\"></div>";
        } else {
            $sHtml .= self::FilterXSS($this->s_content);
        }
        $sHtml .= "</body>\n";
        $sHtml .= "</html>\n";
        if ($this->GetOutputFormat() == 'html') {
            $oKPI = new ExecutionKPI();
            echo $sHtml;
            $oKPI->ComputeAndReport('Echoing (' . round(strlen($sHtml) / 1024) . ' Kb)');
        } else {
            if ($this->GetOutputFormat() == 'pdf' && $this->IsOutputFormatAvailable('pdf')) {
                if (@is_readable(APPROOT . 'lib/MPDF/mpdf.php')) {
                    require_once APPROOT . 'lib/MPDF/mpdf.php';
                    $oMPDF = new mPDF('c');
                    $oMPDF->mirroMargins = false;
                    if ($this->a_base['href'] != '') {
                        $oMPDF->setBasePath($this->a_base['href']);
                        // Seems that the <BASE> tag is not recognized by mPDF...
                    }
                    $oMPDF->showWatermarkText = true;
                    if ($this->GetOutputOption('pdf', 'template_path')) {
                        $oMPDF->setImportUse();
                        // Allow templates
                        $oMPDF->SetDocTemplate($this->GetOutputOption('pdf', 'template_path'), 1);
                    }
                    $oMPDF->WriteHTML($sHtml);
                    $sOutputName = $this->s_title . '.pdf';
                    if ($this->GetOutputOption('pdf', 'output_name')) {
                        $sOutputName = $this->GetOutputOption('pdf', 'output_name');
                    }
                    $oMPDF->Output($sOutputName, 'I');
                }
            }
        }
        DBSearch::RecordQueryTrace();
        ExecutionKPI::ReportStats();
    }
コード例 #7
0
ファイル: rest.php プロジェクト: leandroborgeseng/bhtm
// Output the results
//
$sResponse = json_encode($oResult);
$oP->add_header('Access-Control-Allow-Origin: *');
$sCallback = utils::ReadParam('callback', null);
if ($sCallback == null) {
    $oP->SetContentType('application/json');
    $oP->add($sResponse);
} else {
    $oP->SetContentType('application/javascript');
    $oP->add($sCallback . '(' . $sResponse . ')');
}
$oP->Output();
// Log usage
//
if (MetaModel::GetConfig()->Get('log_rest_service')) {
    $oLog = new EventRestService();
    $oLog->SetTrim('userinfo', UserRights::GetUser());
    $oLog->Set('version', $sVersion);
    $oLog->Set('operation', $sOperation);
    $oLog->SetTrim('json_input', $sJsonString);
    $oLog->Set('provider', $sProvider);
    $sMessage = $oResult->message;
    if (empty($oResult->message)) {
        $sMessage = 'Ok';
    }
    $oLog->SetTrim('message', $sMessage);
    $oLog->Set('code', $oResult->code);
    $oLog->SetTrim('json_output', $sResponse);
    $oLog->DBInsertNoReload();
}
コード例 #8
0
 protected function DoExecute()
 {
     $sUser = '******';
     echo "<p>Totor: " . (UserRights::CheckCredentials('Totor', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>Romain: " . (UserRights::CheckCredentials('Romain', 'toto') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: "******"</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     echo "<p>Denis (impersonate) : " . (UserRights::Impersonate('Denis', 'tutu') ? 'ok' : 'NO') . "</p>\n";
     echo "<p>User: "******"</p>\n";
     echo "<p>On behalf of..." . UserRights::GetRealUser() . "</p>\n";
     $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT bizOrganization"));
     echo "<p>IsActionAllowed..." . (UserRights::IsActionAllowed('bizOrganization', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsStimulusAllowed..." . (UserRights::IsStimulusAllowed('bizOrganization', 'myStimulus', $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     echo "<p>IsActionAllowedOnAttribute..." . (UserRights::IsActionAllowedOnAttribute('bizOrganization', 'myattribute', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO') . "</p>\n";
     return true;
 }
コード例 #9
0
 protected function DeleteConnectedNetworkDevice()
 {
     $iNetworkDeviceID = $this->Get('networkdevice_id');
     $iDeviceID = $this->Get('connectableci_id');
     $oDevice = MetaModel::GetObject('ConnectableCI', $this->Get('connectableci_id'));
     $sOQL = "SELECT  lnkConnectableCIToNetworkDevice WHERE connectableci_id = :device AND networkdevice_id = :network AND network_port = :nwport AND device_port = :devport";
     $oConnectionSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('network' => $this->Get('connectableci_id'), 'device' => $this->Get('networkdevice_id'), 'devport' => $this->Get('network_port'), 'nwport' => $this->Get('device_port')));
     $iAlreadyExist = $oConnectionSet->count();
     if (get_class($oDevice) == 'NetworkDevice' && $iAlreadyExist != 0) {
         $oMyChange = MetaModel::NewObject("CMDBChange");
         $oMyChange->Set("date", time());
         if (UserRights::IsImpersonated()) {
             $sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUser(), UserRights::GetUser());
         } else {
             $sUserString = UserRights::GetUser();
         }
         $oMyChange->Set("userinfo", $sUserString);
         $iChangeId = $oMyChange->DBInsert();
         $oConnection = $oConnectionSet->Fetch();
         $oConnection->DBDeleteTracked($oMyChange);
     }
 }