コード例 #1
0
 /**
  * Handler called after the creation/update of the database schema
  * @param $oConfiguration Config The new configuration of the application
  * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  * @param $sCurrentVersion string Current version number of the module
  */
 public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
 {
     // Bug #464 - start_date was both in Ticket and Change tables
     //
     $sSourceTable = 'change';
     $sSourceKeyField = 'id';
     $sTargetTable = 'ticket';
     $sTargetKeyField = 'id';
     $sField = 'start_date';
     if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField)) {
         SetupPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
         $sRepair = "UPDATE `{$sTargetTable}`, `{$sSourceTable}` SET `{$sTargetTable}`.`{$sField}` = `{$sSourceTable}`.`{$sField}` WHERE `{$sTargetTable}`.`{$sField}` IS NULL AND`{$sTargetTable}`.`{$sTargetKeyField}` = `{$sSourceTable}`.`{$sSourceKeyField}`";
         CMDBSource::Query($sRepair);
     }
 }
コード例 #2
0
 /**
  * Handler called after the creation/update of the database schema
  * @param $oConfiguration Config The new configuration of the application
  * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
  * @param $sCurrentVersion string Current version number of the module
  */
 public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
 {
     // For each record having item_org_id unset,
     //    get the org_id from the container object
     //
     // Prerequisite: change null into 0 (workaround to the fact that we cannot use IS NULL in OQL)
     SetupPage::log_info("Initializing attachment/item_org_id - null to zero");
     $sTableName = MetaModel::DBGetTable('Attachment');
     $sRepair = "UPDATE `{$sTableName}` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL";
     CMDBSource::Query($sRepair);
     SetupPage::log_info("Initializing attachment/item_org_id - zero to the container");
     $oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_org_id = 0");
     $oSet = new DBObjectSet($oSearch);
     $iUpdated = 0;
     while ($oAttachment = $oSet->Fetch()) {
         $oContainer = MetaModel::GetObject($oAttachment->Get('item_class'), $oAttachment->Get('item_id'), false, true);
         if ($oContainer) {
             $oAttachment->SetItem($oContainer, true);
             $iUpdated++;
         }
     }
     SetupPage::log_info("Initializing attachment/item_org_id - {$iUpdated} records have been adjusted");
 }
コード例 #3
0
}
require 'config/init.php';
$default_prefix = 'table';
$bases_path = 'setup/bases/';
$info_ext = '.MYD';
$data_ext = '.FRM';
$config['s_dir'] = 'setup/';
$config['s_plug_dir'] = 'setup/plugins/';
$config['s_inc_dir'] = 'setup/inc/';
$config['s_lng_dir'] = 'setup/lng/';
$config['s_mod_dir'] = 'setup/mods/';
$config['s_tpl_dir'] = 'setup/template/';
include_once $config['s_inc_dir'] . 'functions.php';
include_once $config['s_inc_dir'] . 'template.php';
// Шаблон
include_once $config['s_inc_dir'] . 'setup.class.php';
// Класс управления инсталлятором
include_once $config['s_inc_dir'] . 'plugins.php';
// Поддержка плагинов
include_once $config['s_lng_dir'] . 'lang-russian.php';
// Мультиязычность
$site = new SetupPage();
$site->InitPage();
$site->AddJSFile($config['s_inc_dir'] . 'functions.js', true, true);
$setup = new Setup();
if (isset($_GET['mod'])) {
    $mod = SafeEnv($_GET['mod'], 255, str);
} else {
    $mod = '';
}
$setup->Page($mod);
コード例 #4
0
ファイル: setup.php プロジェクト: BackupTheBerlios/reson-svn
<?php

/*
 * Created on 20.03.2007
 *
 * With this page it is possible to add new projects (exams) to the site
 * 
 * Licenced under GPL: http://www.gnu.org/licenses/gpl.txt
 *
 */
//Check for PHP 5:
if (version_compare("5.0.0", phpversion()) > 0) {
    echo "<html><head><title>PHP 5 required</title></head><body><h1>Error</h1><p>This program requires PHP 5.0.0 or later.</p></body></html>";
    exit;
}
require_once 'classes/autoload.php';
$page = new SetupPage();
$page->render();
コード例 #5
0
 /**
  * Maps an external key to its (newly created) value
  */
 protected function ResolveExternalKeys()
 {
     foreach ($this->m_aObjectsCache as $sClass => $oObjList) {
         foreach ($oObjList as $oTargetObj) {
             $bChanged = false;
             $sClass = get_class($oTargetObj);
             foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
                 if ($oAttDef->IsExternalKey() && $oTargetObj->Get($sAttCode) < 0) {
                     $sTargetClass = $oAttDef->GetTargetClass();
                     $iTempKey = $oTargetObj->Get($sAttCode);
                     $iExtKey = $this->GetObjectKey($sTargetClass, -$iTempKey);
                     if ($iExtKey == 0) {
                         $sMsg = "unresolved extkey in {$sClass}::" . $oTargetObj->GetKey() . "(" . $oTargetObj->GetName() . ")::{$sAttCode}={$sTargetClass}::{$iTempKey}";
                         SetupPage::log_warning($sMsg);
                         $this->m_aWarnings[] = $sMsg;
                         //echo "<pre>aKeys[".$sTargetClass."]:\n";
                         //print_r($this->m_aKeys[$sTargetClass]);
                         //echo "</pre>\n";
                     } else {
                         $bChanged = true;
                         $oTargetObj->Set($sAttCode, $iExtKey);
                     }
                 }
             }
             if ($bChanged) {
                 try {
                     if (is_subclass_of($oTargetObj, 'CMDBObject')) {
                         $oTargetObj->DBUpdateTracked($this->m_oChange);
                     } else {
                         $oTargetObj->DBUpdate();
                     }
                 } catch (Exception $e) {
                     $this->m_aErrors[] = "The object changes could not be tracked - {$sClass}/{$iExtKey} - " . $e->getMessage();
                 }
             }
         }
     }
     return true;
 }
コード例 #6
0
 protected function LogError($sMsg)
 {
     SetupPage::log('Error - ' . $sMsg);
 }
コード例 #7
0
 /**
  * Check if the user is already authentified, if yes, then performs some additional validations to redirect towards the desired "portal"
  * @param string|null $sRequestedPortalId The requested "portal" interface, null for any
  * @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  */
 static function DoLoginEx($sRequestedPortalId = null, $bMustBeAdmin = false, $iOnExit = self::EXIT_PROMPT)
 {
     $operation = utils::ReadParam('loginop', '');
     $sMessage = self::HandleOperations($operation);
     // May exit directly
     $iRet = self::Login($iOnExit);
     if ($iRet == self::EXIT_CODE_OK) {
         if ($bMustBeAdmin && !UserRights::IsAdministrator()) {
             if ($iOnExit == self::EXIT_RETURN) {
                 return self::EXIT_CODE_MUSTBEADMIN;
             } else {
                 require_once APPROOT . '/setup/setuppage.class.inc.php';
                 $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
                 $oP->add("<h1>" . Dict::S('UI:Login:Error:AccessAdmin') . "</h1>\n");
                 $oP->p("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/logoff.php\">" . Dict::S('UI:LogOffMenu') . "</a>");
                 $oP->output();
                 exit;
             }
         }
         $iRet = call_user_func(array(self::$sHandlerClass, 'ChangeLocation'), $sRequestedPortalId, $iOnExit);
     }
     if ($iOnExit == self::EXIT_RETURN) {
         return $iRet;
     } else {
         return $sMessage;
     }
 }
コード例 #8
0
 public static function log($sText)
 {
     SetupPage::log($sText);
 }
コード例 #9
0
ファイル: benchmark.php プロジェクト: besmirzanaj/itop-code
/**
 * Ask the user what are the settings for the data load
 */
function DisplayStep1(SetupPage $oP)
{
    $sNextOperation = 'step2';
    $oP->add("<h1>iTop benchmarking</h1>\n");
    $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Evaluating real plans...', 10)\">\n");
    $oP->add("<fieldset><legend>Data load configuration</legend>\n");
    $aForm = array();
    $aForm[] = array('label' => "Contacts:", 'input' => "<input id=\"from\" type=\"text\" name=\"plannedcontacts\" value=\"100\">", 'help' => '');
    $aForm[] = array('label' => "Contracts:", 'input' => "<input id=\"from\" type=\"text\" name=\"plannedcontracts\" value=\"10\">", 'help' => '');
    $oP->form($aForm);
    $oP->add("</fieldset>\n");
    $oP->add("<input type=\"hidden\" name=\"operation\" value=\"create_structure\">\n");
    $oP->add("<button type=\"submit\">Next >></button>\n");
    $oP->add("</form>\n");
    $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Evaluating real plans...', 10)\">\n");
    $oP->add("<fieldset><legend>Data load configuration</legend>\n");
    $aForm = array();
    $aForm[] = array('label' => "Main CIs:", 'input' => "<input id=\"to\" type=\"text\" name=\"plannedcis\" value=\"70\">", 'help' => ' exclude interfaces, subnets or any other type of secondary CI');
    $oP->form($aForm);
    $oP->add("</fieldset>\n");
    $oP->add("<input type=\"hidden\" name=\"operation\" value=\"create_cis\">\n");
    $oP->add("<button type=\"submit\">Next >></button>\n");
    $oP->add("</form>\n");
    $oP->add("<form method=\"post\" onSubmit=\"return DoSubmit('Evaluating real plans...', 10)\">\n");
    $oP->add("<fieldset><legend>Data load configuration</legend>\n");
    $aForm = array();
    $aForm[] = array('label' => "Tickets:", 'input' => "<input id=\"to\" type=\"text\" name=\"plannedtickets\" value=\"200\">", 'help' => ' 50% incidents, 50% changes');
    $aForm[] = array('label' => "CIs for the big ticket:", 'input' => "<input id=\"to\" type=\"text\" name=\"plannedbigticketcis\" value=\"200\">", 'help' => 'Number of CI for the single big ticket');
    $oP->form($aForm);
    $oP->add("</fieldset>\n");
    $oP->add("<input type=\"hidden\" name=\"operation\" value=\"create_tickets\">\n");
    $oP->add("<button type=\"submit\">Next >></button>\n");
    $oP->add("</form>\n");
}
コード例 #10
0
 protected function log_ok($sText)
 {
     SetupPage::log_ok($sText);
 }
コード例 #11
0
 /**
  * Check if the user is already authentified, if yes, then performs some additional validations:
  * - if $bMustBeAdmin is true, then the user must be an administrator, otherwise an error is displayed
  * - if $bIsAllowedToPortalUsers is false and the user has only access to the portal, then the user is redirected to the portal
  * @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
  * @param bool $bIsAllowedToPortalUsers Whether or not the current page is considered as part of the portal
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  */
 static function DoLogin($bMustBeAdmin = false, $bIsAllowedToPortalUsers = false, $iOnExit = self::EXIT_PROMPT)
 {
     $sMessage = '';
     // In case we need to return a message to the calling web page
     $operation = utils::ReadParam('loginop', '');
     if ($operation == 'logoff') {
         if (isset($_SESSION['login_mode'])) {
             $sLoginMode = $_SESSION['login_mode'];
         } else {
             $aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
             if (count($aAllowedLoginTypes) > 0) {
                 $sLoginMode = $aAllowedLoginTypes[0];
             } else {
                 $sLoginMode = 'form';
             }
         }
         self::ResetSession();
         $oPage = self::NewLoginWebPage();
         $oPage->DisplayLoginForm($sLoginMode, false);
         $oPage->output();
         exit;
     } else {
         if ($operation == 'forgot_pwd') {
             $oPage = self::NewLoginWebPage();
             $oPage->DisplayForgotPwdForm();
             $oPage->output();
             exit;
         } else {
             if ($operation == 'forgot_pwd_go') {
                 $oPage = self::NewLoginWebPage();
                 $oPage->ForgotPwdGo();
                 $oPage->output();
                 exit;
             } else {
                 if ($operation == 'reset_pwd') {
                     $oPage = self::NewLoginWebPage();
                     $oPage->DisplayResetPwdForm();
                     $oPage->output();
                     exit;
                 } else {
                     if ($operation == 'do_reset_pwd') {
                         $oPage = self::NewLoginWebPage();
                         $oPage->DoResetPassword();
                         $oPage->output();
                         exit;
                     } else {
                         if ($operation == 'change_pwd') {
                             $sAuthUser = $_SESSION['auth_user'];
                             UserRights::Login($sAuthUser);
                             // Set the user's language
                             $oPage = self::NewLoginWebPage();
                             $oPage->DisplayChangePwdForm();
                             $oPage->output();
                             exit;
                         }
                     }
                 }
             }
         }
     }
     if ($operation == 'do_change_pwd') {
         $sAuthUser = $_SESSION['auth_user'];
         UserRights::Login($sAuthUser);
         // Set the user's language
         $sOldPwd = utils::ReadPostedParam('old_pwd', '', false, 'raw_data');
         $sNewPwd = utils::ReadPostedParam('new_pwd', '', false, 'raw_data');
         if (UserRights::CanChangePassword() && (!UserRights::CheckCredentials($sAuthUser, $sOldPwd) || !UserRights::ChangePassword($sOldPwd, $sNewPwd))) {
             $oPage = self::NewLoginWebPage();
             $oPage->DisplayChangePwdForm(true);
             // old pwd was wrong
             $oPage->output();
             exit;
         }
         $sMessage = Dict::S('UI:Login:PasswordChanged');
     }
     $iRet = self::Login($iOnExit);
     if ($iRet == self::EXIT_CODE_OK) {
         if ($bMustBeAdmin && !UserRights::IsAdministrator()) {
             if ($iOnExit == self::EXIT_RETURN) {
                 return self::EXIT_CODE_MUSTBEADMIN;
             } else {
                 require_once APPROOT . '/setup/setuppage.class.inc.php';
                 $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
                 $oP->add("<h1>" . Dict::S('UI:Login:Error:AccessAdmin') . "</h1>\n");
                 $oP->p("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/logoff.php\">" . Dict::S('UI:LogOffMenu') . "</a>");
                 $oP->output();
                 exit;
             }
         }
         $iRet = call_user_func(array(self::$sHandlerClass, 'ChangeLocation'), $bIsAllowedToPortalUsers, $iOnExit);
     }
     if ($iOnExit == self::EXIT_RETURN) {
         return $iRet;
     } else {
         return $sMessage;
     }
 }
コード例 #12
0
 /**
  * Helper to modify an enum value	
  * The change is made in the datamodel definition, but the value has to be changed in the DB as well	 	 
  * Must be called BEFORE DB update, i.e within an implementation of BeforeDatabaseCreation()
  * 	 
  * @param string $sClass A valid class name
  * @param string $sAttCode The enum attribute code
  * @param string $sFrom Original value (already INVALID in the current datamodel)	 	
  * @param string $sTo New value (valid in the current datamodel)
  * @return void	 	 	
  */
 public static function RenameEnumValueInDB($sClass, $sAttCode, $sFrom, $sTo)
 {
     $sOriginClass = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
     $sTableName = MetaModel::DBGetTable($sOriginClass);
     $oAttDef = MetaModel::GetAttributeDef($sOriginClass, $sAttCode);
     if ($oAttDef instanceof AttributeEnum) {
         $oValDef = $oAttDef->GetValuesDef();
         if ($oValDef) {
             $aNewValues = array_keys($oValDef->GetValues(array(), ""));
             if (in_array($sTo, $aNewValues)) {
                 $aAllValues = $aNewValues;
                 $aAllValues[] = $sFrom;
                 if (!in_array($sFrom, $aNewValues)) {
                     $sEnumCol = $oAttDef->Get("sql");
                     $sNullSpec = $oAttDef->IsNullAllowed() ? 'NULL' : 'NOT NULL';
                     if (strtolower($sTo) == strtolower($sFrom)) {
                         SetupPage::log_info("Changing enum in DB - {$sClass}::{$sAttCode} from '{$sFrom}' to '{$sTo}' (just a change in the case)");
                         $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aNewValues)) . ") {$sNullSpec}";
                         $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                         CMDBSource::Query($sRepair);
                     } else {
                         // 1st - Allow both values in the column definition
                         //
                         SetupPage::log_info("Changing enum in DB - {$sClass}::{$sAttCode} from '{$sFrom}' to '{$sTo}'");
                         $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aAllValues)) . ") {$sNullSpec}";
                         $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                         CMDBSource::Query($sRepair);
                         // 2nd - Change the old value into the new value
                         //
                         $sRepair = "UPDATE `{$sTableName}` SET `{$sEnumCol}` = '{$sTo}' WHERE `{$sEnumCol}` = BINARY '{$sFrom}'";
                         CMDBSource::Query($sRepair);
                         $iAffectedRows = CMDBSource::AffectedRows();
                         SetupPage::log_info("Changing enum in DB - {$iAffectedRows} rows updated");
                         // 3rd - Remove the useless value from the column definition
                         //
                         $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aNewValues)) . ") {$sNullSpec}";
                         $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                         CMDBSource::Query($sRepair);
                         SetupPage::log_info("Changing enum in DB - removed useless value '{$sFrom}'");
                     }
                 } else {
                     SetupPage::log_warning("Changing enum in DB - {$sClass}::{$sAttCode} - '{$sFrom}' is still a valid value (" . implode(', ', $aNewValues) . ")");
                 }
             } else {
                 SetupPage::log_warning("Changing enum in DB - {$sClass}::{$sAttCode} - '{$sTo}' is not a known value (" . implode(', ', $aNewValues) . ")");
             }
         }
     }
 }
コード例 #13
0
            $oPage = new ajax_page('');
            $oDummyController = new WizardController('');
            if (is_subclass_of($sClass, 'WizardStep')) {
                $oStep = new $sClass($oDummyController, $sState);
                $sConfigFile = utils::GetConfigFilePath();
                if (file_exists($sConfigFile) && !is_writable($sConfigFile) && $oStep->RequiresWritableConfig()) {
                    $oPage->error("<b>Error:</b> the configuration file '" . $sConfigFile . "' already exists and cannot be overwritten.");
                    $oPage->p("The wizard cannot modify the configuration file for you. If you want to upgrade " . ITOP_APPLICATION . ", make sure that the file '<b>" . realpath($sConfigFile) . "</b>' can be modified by the web server.");
                    $oPage->output();
                } else {
                    $oStep->AsyncAction($oPage, $sActionCode, $aParams);
                }
            }
            $oPage->output();
            break;
        default:
            throw new Exception("Error unsupported operation '{$sOperation}'");
    }
} catch (Exception $e) {
    header("HTTP/1.0 500 Internal server error.");
    echo "<p>An error happened while processing the installation:</p>\n";
    echo '<p>' . $e . "</p>\n";
    SetupPage::log_error("An error happened while processing the installation: " . $e);
}
if (function_exists('memory_get_peak_usage')) {
    if ($sOperation == 'file') {
        SetupPage::log_info("loading file '{$sFileName}', peak memory usage. " . memory_get_peak_usage());
    } else {
        SetupPage::log_info("operation '{$sOperation}', peak memory usage. " . memory_get_peak_usage());
    }
}
コード例 #14
0
ファイル: index.php プロジェクト: kira8565/ITOP203-ZHCN
                $oLog->Set('issue', $e->GetIssue());
                $oLog->Set('impact', 'Page could not be displayed');
                $oLog->Set('callstack', $e->getTrace());
                $oLog->Set('data', $e->getContextData());
                $oLog->DBInsertNoReload();
            } catch (Exception $e) {
                IssueLog::Error("Failed to log issue into the DB");
            }
        }
        IssueLog::Error($e->getMessage());
    }
    // For debugging only
    //throw $e;
} catch (Exception $e) {
    require_once APPROOT . '/setup/setuppage.class.inc.php';
    $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
    $oP->add("<h1>" . Dict::S('UI:FatalErrorMessage') . "</h1>\n");
    $oP->error(Dict::Format('UI:Error_Details', $e->getMessage()));
    //$oP->p($e->getTraceAsString());
    $oP->output();
    if (MetaModel::IsLogEnabledIssue()) {
        if (MetaModel::IsValidClass('EventIssue')) {
            try {
                $oLog = new EventIssue();
                $oLog->Set('message', $e->getMessage());
                $oLog->Set('userinfo', '');
                $oLog->Set('issue', 'PHP Exception');
                $oLog->Set('impact', 'Page could not be displayed');
                $oLog->Set('callstack', $e->getTrace());
                $oLog->Set('data', array());
                $oLog->DBInsertNoReload();
コード例 #15
0
ファイル: update.php プロジェクト: hisapi/his
            $PAGE->body = $PAGE->body . "<a href='?'>" . getTranslation("Click here to use your new & improved HIS Web Interface", $settings) . "</a>";
            $PAGE->body = $PAGE->body . "<br/>";
            $PAGE->body = $PAGE->body . "<br/>";
            $PAGE->body = $PAGE->body . getTranslation("job server update reminder", $settings);
            $PAGE->hide_back = true;
            $PAGE->hide_next = true;
        }
    }
    $PAGE->title = "<h1>" . $title_text . "</h1>";
    if ($database_version != $software_version) {
        $PAGE->body = $PAGE->body . "<br/>";
        $PAGE->body = $PAGE->body . "<br/>";
        if (!isset($_GET['page'])) {
            $PAGE->body = $PAGE->body . getTranslation("Click Submit to execute the update.", $settings);
        } else {
            $PAGE->body = $PAGE->body . getTranslation("Click Submit to execute the next update.", $settings);
        }
    }
    echo $PAGE->content();
    exit;
} elseif ($error_database_from_future_version) {
    $PAGE = new SetupPage(1);
    $PAGE->pagetitle = "Update";
    $PAGE->generate_headers_footers();
    $PAGE->title = "<p>" . getTranslation("Database is using a future schema version", $settings) . "</p>";
    $PAGE->hide_back = true;
    echo $PAGE->content();
    $PAGE->body = getTranslation("downgrade attempt", $settings);
    $PAGE->body = $PAGE->body . "<br/><br/>";
    exit;
}
コード例 #16
0
    /**
     * Displays the specified 'step' of the wizard
     * @param WizardStep $oStep The 'step' to display
     */
    protected function DisplayStep(WizardStep $oStep)
    {
        $oPage = new SetupPage($oStep->GetTitle());
        if ($oStep->RequiresWritableConfig()) {
            $sConfigFile = utils::GetConfigFilePath();
            if (file_exists($sConfigFile)) {
                // The configuration file already exists
                if (!is_writable($sConfigFile)) {
                    $oP = new SetupPage('Installation Cannot Continue');
                    $oP->add("<h2>Fatal error</h2>\n");
                    $oP->error("<b>Error:</b> the configuration file '" . $sConfigFile . "' already exists and cannot be overwritten.");
                    $oP->p("The wizard cannot modify the configuration file for you. If you want to upgrade " . ITOP_APPLICATION . ", make sure that the file '<b>" . realpath($sConfigFile) . "</b>' can be modified by the web server.");
                    $oP->output();
                    return;
                }
            }
        }
        $oPage->add_linked_script('../setup/setup.js');
        $oPage->add_script("function CanMoveForward()\n{\n" . $oStep->JSCanMoveForward() . "\n}\n");
        $oPage->add_script("function CanMoveBackward()\n{\n" . $oStep->JSCanMoveBackward() . "\n}\n");
        $oPage->add('<form id="wiz_form" method="post">');
        $oStep->Display($oPage);
        // Add the back / next buttons and the hidden form
        // to store the parameters
        $oPage->add('<input type="hidden" id="_class" name="_class" value="' . get_class($oStep) . '"/>');
        $oPage->add('<input type="hidden" id="_state" name="_state" value="' . $oStep->GetState() . '"/>');
        foreach ($this->aParameters as $sCode => $value) {
            $oPage->add('<input type="hidden" name="_params[' . $sCode . ']" value="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"/>');
        }
        $oPage->add('<input type="hidden" name="_steps" value="' . htmlentities(json_encode($this->aSteps), ENT_QUOTES, 'UTF-8') . '"/>');
        $oPage->add('<table style="width:100%;"><tr>');
        if (count($this->aSteps) > 0 && $oStep->CanMoveBackward()) {
            $oPage->add('<td style="text-align: left"><button id="btn_back" type="submit" name="operation" value="back"> &lt;&lt; Back </button></td>');
        }
        if ($oStep->CanMoveForward()) {
            $oPage->add('<td style="text-align:right;"><button id="btn_next" class="default" type="submit" name="operation" value="next">' . htmlentities($oStep->GetNextButtonLabel(), ENT_QUOTES, 'UTF-8') . '</button></td>');
        }
        $oPage->add('</tr></table>');
        $oPage->add("</form>");
        $oPage->add('<div id="async_action" style="display:none;overflow:auto;max-height:100px;color:#F00;font-size:small;"></div>');
        // The div may become visible in case of error
        // Hack to have the "Next >>" button, be the default button, since the first submit button in the form is the default one
        $oPage->add_ready_script(<<<EOF

\$('form').each(function () {
\tvar thisform = \$(this);
\t\tthisform.prepend(thisform.find('button.default').clone().removeAttr('id').removeAttr('disabled').css({
\t\tposition: 'absolute',
\t\tleft: '-999px',
\t\ttop: '-999px',
\t\theight: 0,
\t\twidth: 0
\t}));
});
\$('#btn_back').click(function() { \$('#wiz_form').data('back', true); });

\$('#wiz_form').submit(function() {
\tif (\$(this).data('back'))
\t{
\t\treturn CanMoveBackward();
\t}
\telse
\t{
\t\treturn CanMoveForward();
\t} 
});

\$('#wiz_form').data('back', false);
WizardUpdateButtons();

EOF
);
        $oPage->output();
    }
コード例 #17
0
ファイル: email.test.php プロジェクト: leandroborgeseng/bhtm
/**
 * Display the form for the second step of the configuration wizard
 * which consists in sending an email, which maybe a problem under Windows
 */
function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
{
    //$sNextOperation = 'step3';
    $oP->add("<h1>iTop configuration wizard</h1>\n");
    $oP->add("<h2>Step 2: send an email</h2>\n");
    $oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n");
    $oP->add("<form method=\"post\">\n");
    $oEmail = new Email();
    $oEmail->SetRecipientTO($sTo);
    $oEmail->SetRecipientFrom($sFrom);
    $oEmail->SetSubject("Test iTop");
    $oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>");
    $iRes = $oEmail->Send($aIssues, true);
    switch ($iRes) {
        case EMAIL_SEND_OK:
            $sTransport = MetaModel::GetConfig()->Get('email_transport');
            if ($sTransport == 'LogFile') {
                $oP->ok("The email has been logged into the file " . APPROOT . "/log/mail.log.");
            } else {
                $oP->ok("The email has been sent, check your inbox for the incoming mail...");
            }
            $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
            break;
        case EMAIL_SEND_PENDING:
            $oP->ok("Email queued");
            $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
            break;
        case EMAIL_SEND_ERROR:
            foreach ($aIssues as $sError) {
                $oP->error($sError);
            }
            $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
            break;
    }
}
コード例 #18
0
 /**
  * Helper to recursively cleanup a directory
  */
 public static function tidydir($dir)
 {
     if (strlen(trim($dir)) == 0 || $dir == '/' || $dir == '\\') {
         throw new Exception("Attempting to delete directory: '{$dir}'");
     }
     $aFiles = scandir($dir);
     // Warning glob('.*') does not seem to return the broken symbolic links, thus leaving a non-empty directory
     if ($aFiles !== false) {
         foreach ($aFiles as $file) {
             if ($file != '.' && $file != '..') {
                 if (is_dir($dir . '/' . $file)) {
                     self::tidydir($dir . '/' . $file);
                     rmdir($dir . '/' . $file);
                 } else {
                     if (!unlink($dir . '/' . $file)) {
                         SetupPage::log("Warning - FAILED to remove file '{$dir}/{$file}'");
                     } else {
                         if (file_exists($dir . '/' . $file)) {
                             SetupPage::log("Warning - FAILED to remove file '{$dir}/.{$file}'");
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #19
0
ファイル: install.php プロジェクト: hisapi/his
        //ob_end_flush();
        $PAGE->hide_back = true;
        echo $PAGE->content();
        echo "<script>\nfunction WindowLoad(event) {\n    document.getElementById('btnSubmit').disabled=true;\n    setTimeout('document.forms[0].submit()',1000);\n}\n\nif (window.addEventListener) { // Mozilla, Netscape, Firefox\n    window.addEventListener('load', WindowLoad, false);\n} else if (window.attachEvent) { // IE\n    window.attachEvent('onload', WindowLoad);\n}\n\n</script>";
        exit;
    }
}
if (isset($_GET['page'])) {
    if ($_GET['page'] == $last_step_of_library_installation + 1 && $DB_CONNECT && $FS_CONNECT && file_exists($BIN_DIR . $PATH_SEPERATOR . "his-config.php")) {
        $check_user = new user_user_name();
        $check_user->get_from_hashrange($_POST['user_name']);
        $pw = sha1($settings['salt1']['@attributes']['value'] . $_POST['admin_password'] . $_POST['user_name'] . $settings['salt2']['@attributes']['value']);
        if ($check_user->pw != $pw) {
            exit;
        }
        $PAGE = new SetupPage($_GET['page']);
        $PAGE->title = "<p>";
        $PAGE->title = $PAGE->title . getTranslation("Setup complete.", $settings);
        $PAGE->body = $PAGE->body . "</p>";
        $PAGE->body = $PAGE->body . "<table width='100%'><tr><td width='50%' valign='top'><p>";
        $PAGE->body = $PAGE->body . getTranslation("Setup was successful.  Click ", $settings);
        $PAGE->body = $PAGE->body . " <a href='index.php?v=login'>";
        $PAGE->body = $PAGE->body . getTranslation("here", $settings);
        $PAGE->body = $PAGE->body . "</a> ";
        $PAGE->body = $PAGE->body . getTranslation(" to login to HIS.", $settings);
        $PAGE->body = $PAGE->body . "</p></td>";
        $PAGE->body = $PAGE->body . "<td valign='top' align='right'>";
        $PAGE->body = $PAGE->body . "<img src='images/checkmark.png'/>";
        $PAGE->body = $PAGE->body . "</td></tr></table>";
        $PAGE->hide_back = true;
        $PAGE->hide_next = true;
コード例 #20
0
 /**
  * Helper to modify an enum value	
  * The change is made in the datamodel definition, but the value has to be changed in the DB as well	 	 
  * Must be called BEFORE DB update, i.e within an implementation of BeforeDatabaseCreation()
  * This helper does change ONE value at a time	 
  * 	 
  * @param string $sClass A valid class name
  * @param string $sAttCode The enum attribute code
  * @param string $sFrom Original value (already INVALID in the current datamodel)	 	
  * @param string $sTo New value (valid in the current datamodel)
  * @return void	 	 	
  */
 public static function RenameEnumValueInDB($sClass, $sAttCode, $sFrom, $sTo)
 {
     try {
         $sOriginClass = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
         $sTableName = MetaModel::DBGetTable($sOriginClass);
         $oAttDef = MetaModel::GetAttributeDef($sOriginClass, $sAttCode);
         if ($oAttDef instanceof AttributeEnum) {
             $oValDef = $oAttDef->GetValuesDef();
             if ($oValDef) {
                 $aNewValues = array_keys($oValDef->GetValues(array(), ""));
                 if (in_array($sTo, $aNewValues)) {
                     $sEnumCol = $oAttDef->Get("sql");
                     $aFields = CMDBSource::QueryToArray("SHOW COLUMNS FROM `{$sTableName}` WHERE Field = '{$sEnumCol}'");
                     if (isset($aFields[0]['Type'])) {
                         $sColType = $aFields[0]['Type'];
                         // Note: the parsing should rely on str_getcsv (requires PHP 5.3) to cope with escaped string
                         if (preg_match("/^enum\\(\\'(.*)\\'\\)\$/", $sColType, $aMatches)) {
                             $aCurrentValues = explode("','", $aMatches[1]);
                         }
                     }
                     if (!in_array($sFrom, $aNewValues)) {
                         if (!in_array($sTo, $aCurrentValues)) {
                             $sNullSpec = $oAttDef->IsNullAllowed() ? 'NULL' : 'NOT NULL';
                             if (strtolower($sTo) == strtolower($sFrom)) {
                                 SetupPage::log_info("Changing enum in DB - {$sClass}::{$sAttCode} from '{$sFrom}' to '{$sTo}' (just a change in the case)");
                                 $aTargetValues = array();
                                 foreach ($aCurrentValues as $sValue) {
                                     if ($sValue == $sFrom) {
                                         $sValue = $sTo;
                                     }
                                     $aTargetValues[] = $sValue;
                                 }
                                 $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aTargetValues)) . ") {$sNullSpec}";
                                 $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                                 CMDBSource::Query($sRepair);
                             } else {
                                 // 1st - Allow both values in the column definition
                                 //
                                 SetupPage::log_info("Changing enum in DB - {$sClass}::{$sAttCode} from '{$sFrom}' to '{$sTo}'");
                                 $aAllValues = $aCurrentValues;
                                 $aAllValues[] = $sTo;
                                 $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aAllValues)) . ") {$sNullSpec}";
                                 $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                                 CMDBSource::Query($sRepair);
                                 // 2nd - Change the old value into the new value
                                 //
                                 $sRepair = "UPDATE `{$sTableName}` SET `{$sEnumCol}` = '{$sTo}' WHERE `{$sEnumCol}` = BINARY '{$sFrom}'";
                                 CMDBSource::Query($sRepair);
                                 $iAffectedRows = CMDBSource::AffectedRows();
                                 SetupPage::log_info("Changing enum in DB - {$iAffectedRows} rows updated");
                                 // 3rd - Remove the useless value from the column definition
                                 //
                                 $aTargetValues = array();
                                 foreach ($aCurrentValues as $sValue) {
                                     if ($sValue == $sFrom) {
                                         $sValue = $sTo;
                                     }
                                     $aTargetValues[] = $sValue;
                                 }
                                 $sColumnDefinition = "ENUM(" . implode(",", CMDBSource::Quote($aTargetValues)) . ") {$sNullSpec}";
                                 $sRepair = "ALTER TABLE `{$sTableName}` MODIFY `{$sEnumCol}` {$sColumnDefinition}";
                                 CMDBSource::Query($sRepair);
                                 SetupPage::log_info("Changing enum in DB - removed useless value '{$sFrom}'");
                             }
                         }
                     } else {
                         SetupPage::log_warning("Changing enum in DB - {$sClass}::{$sAttCode} - '{$sFrom}' is still a valid value (" . implode(', ', $aNewValues) . ")");
                     }
                 } else {
                     SetupPage::log_warning("Changing enum in DB - {$sClass}::{$sAttCode} - '{$sTo}' is not a known value (" . implode(', ', $aNewValues) . ")");
                 }
             }
         }
     } catch (Exception $e) {
         SetupPage::log_warning("Changing enum in DB - {$sClass}::{$sAttCode} - '{$sTo}' failed. Reason " . $e->getMessage());
     }
 }
コード例 #21
0
ファイル: email.test.php プロジェクト: kira8565/ITOP203-ZHCN
/**
 * Display the form for the second step of the configuration wizard
 * which consists in sending an email, which maybe a problem under Windows
 */
function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
{
    //$sNextOperation = 'step3';
    $oP->add("<h1>iTop configuration wizard</h1>\n");
    $oP->add("<h2>Step 2: send an email</h2>\n");
    $oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n");
    $oP->add("<form method=\"post\">\n");
    $oEmail = new Email();
    $oEmail->SetRecipientTO($sTo);
    $oEmail->SetRecipientFrom($sFrom);
    $oEmail->SetSubject("Test iTop");
    $oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>");
    $iRes = $oEmail->Send($aIssues, true);
    switch ($iRes) {
        case EMAIL_SEND_OK:
            $oP->ok("The email has been sent, you may now check that the email will arrive...");
            break;
        case EMAIL_SEND_PENDING:
            $oP->ok("Email queued");
            $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
            break;
        case EMAIL_SEND_ERROR:
            foreach ($aIssues as $sError) {
                $oP->error($sError);
            }
            $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n");
            break;
    }
}