* credentials that the user logged in with previously ... these are stored * in the MapGuide session. * It is possible for the user to re-authenticate using a different set of * credentials. Handle this here, but keep the session the same. */ $sessionID = $_REQUEST['session']; session_id(str_replace('_', '-', $sessionID)); session_start(); /* current user is re-authenticating or not? */ if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { $user = new MgUserInformation($_REQUEST['username'], $_REQUEST['password']); $user->SetClientIp(GetClientIp()); $user->SetClientAgent(GetClientAgent()); $user->SetMgSessionId($sessionID); } else { $user = new MgUserInformation($sessionID); $user->SetClientIp(GetClientIp()); $user->SetClientAgent(GetClientAgent()); } /* open a connection to the site. This will generate exceptions if the user * is set up properly - not found, invalid password etc */ $siteConnection = new MgSiteConnection(); $siteConnection->Open($user); /* MgUserInformation doesn't tell us who is logged in so we store it * in the php session for convenience */ if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { $_SESSION['username'] = $_REQUEST['username']; } //echo "<current user: >".$_SESSION['username']. '</current>';
// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // // Usage: // php-cgi updateResource.php user=SomeUserName num=NumberOfResources loop=LoopCount // // require_once "../../../Web/src/PhpApi/constants.php"; require_once "Utils.php"; try { Utils::MapAgentInit(WEBCONFIGINI); $site = new MgSiteConnection(); $cred = new MgUserInformation(); $cred->SetMgUsernamePassword("Administrator", "admin"); $cred->SetLocale("en"); $site->Open($cred); $svc = $site->CreateService(MgServiceType::ResourceService); } catch (MgException $exc) { header("HTTP/1.1 559" . $exc->GetExceptionMessage()); $hdr = "Status: 559 " . $exc->GetExceptionMessage(); header($hdr); echo "<html>\n"; echo "<body>\n"; echo $hdr . "\n"; echo $exc->GetExceptionMessage() . "\n"; echo $exc->GetDetails() . "\n"; echo "</body>\n"; echo "</html>\n";
function BuildViewer($forDwf = true) { global $debug, $webLayoutDefinition, $cmds, $locale; global $sessionId, $username, $password, $orgSessionId; global $mapName; global $product; SetLocalizedFilesPath(GetLocalizationPath()); try { // Initialize web tier with the site configuration file. InitializeWebTier(); //fetch the parameters for this request // GetRequestParameters(); //Open a connection with the server // $createSession = true; $cred = new MgUserInformation(); if ($sessionId != '') { $cred->SetMgSessionId($sessionId); $createSession = false; } else { if ($username != '') { $cred->SetMgUsernamePassword($username, $password); } else { requestAuthentication(); return; } } $site = new MgSiteConnection(); $cred->SetLocale($locale); $cred->SetClientIp(GetClientIp()); $cred->SetClientAgent(GetClientAgent()); $site->Open($cred); if ($createSession) { $site1 = $site->GetSite(); $sessionId = $site1->CreateSession(); if ($forDwf == false) { $orgSessionId = $sessionId; } } //Get a MgWebLayout object initialized with the specified web layout definition // $webLayout = null; try { $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); $webLayoutId = new MgResourceIdentifier($webLayoutDefinition); $webLayout = new MgWebLayout($resourceSrvc, $webLayoutId); } catch (MgUnauthorizedAccessException $e) { requestAuthentication(); return; } catch (MgException $e) { $shortError = $e->GetExceptionMessage(); $longErrorMsg = EscapeForHtml($e->GetDetails()); header("HTTP/1.1 559 "); header('Content-Type: text/html; charset=utf-8'); header("Status: 559 {$shortError}"); echo "<html>\n<body>\n"; echo $longErrorMsg; echo "</body>\n</html>\n"; return; } //calculate the size of the variable elements of the viewer // $toolBar = $webLayout->GetToolBar(); $statusBar = $webLayout->GetStatusBar(); $taskPane = $webLayout->GetTaskPane(); $infoPane = $webLayout->GetInformationPane(); $taskBar = $taskPane->GetTaskBar(); $mapDef = $webLayout->GetMapDefinition(); $startupScriptCode = $webLayout->GetStartupScript(); $selectionColor = $webLayout->GetSelectionColor(); $mapImgFormat = $webLayout->GetMapImageFormat(); $selImgFormat = $webLayout->GetSelectionImageFormat(); $pointBuffer = $webLayout->GetPointSelectionBuffer(); $showTaskPane = $taskPane->IsVisible(); $showTaskBar = $taskBar->IsVisible(); $showStatusbar = $statusBar->IsVisible(); $showToolbar = $toolBar->IsVisible(); $taskPaneWidth = $taskPane->GetWidth(); $toolbarHeight = 30; $taskbarHeight = 30; $statusbarHeight = 26; $taskWidth = $showTaskPane ? $taskPaneWidth : 0; $toolbarHeight = $showToolbar ? $toolbarHeight : 0; $taskbarHeight = $showTaskBar ? $taskbarHeight : 0; $statusbarHeight = $showStatusbar ? $statusbarHeight : 0; //Encode the initial url so that it does not trip any sub-frames (especially if this url has parameters) $taskPaneUrl = urlencode($taskPane->GetInitialTaskUrl()); $vpath = GetSurroundVirtualPath(); $defHome = false; if ($taskPaneUrl == "") { $taskPaneUrl = "gettingstarted.php"; $defHome = true; } $mapDefinitionUrl = urlencode($mapDef); // NOTE: // // We don't open a MgMap because it is being created by mapframe.php that is also probably running // as this script is running. However the naming convention is fixed enough that we can figure out // what to pass to the Task Pane $resId = new MgResourceIdentifier($mapDef); $mapName = $resId->GetName(); $title = $webLayout->GetTitle(); $enablePingServer = $webLayout->GetEnablePingServer(); $showLegend = $infoPane->IsLegendBandVisible(); $showProperties = $infoPane->IsPropertiesBandVisible(); if ($showLegend || $showProperties) { if ($infoPane->IsVisible()) { $infoWidth = $infoPane->GetWidth(); if ($infoWidth < 5) { $infoWidth = 5; } //ensure visible } else { $showProperties = $showLegend = false; $infoWidth = 0; } } else { $infoWidth = 0; } //calculate the url of the inner pages // $srcToolbar = $showToolbar ? 'src="' . $vpath . 'toolbar.php?LOCALE=' . $locale . '"' : ''; $srcStatusbar = $showStatusbar ? 'src="' . $vpath . 'statusbar.php?LOCALE=' . $locale . '"' : ""; $srcTaskFrame = $showTaskPane ? 'src="' . $vpath . 'taskframe.php?MAPNAME=' . $mapName . '&WEBLAYOUT=' . urlencode($webLayoutDefinition) . '&DWF=' . ($forDwf ? "1" : "0") . '&SESSION=' . ($sessionId != "" ? $sessionId : "") . '&LOCALE=' . $locale . '"' : ''; $srcTaskBar = 'src="' . $vpath . 'taskbar.php?LOCALE=' . $locale . '"'; //view center // $ptCenter = $webLayout->GetCenter(); if ($ptCenter == null) { $center = "null"; } else { $coord = $ptCenter->GetCoordinate(); $center = sprintf("new Point(%f, %f)", $coord->GetX(), $coord->GetY()); } //Process commands and declare command objects // $commands = $webLayout->GetCommands(); $cmdObjects = ""; $cmdObject = ""; $navCmdIndex = 0; $searchCmdIndex = 0; $measureCmdIndex = 0; $printCmdIndex = 0; $scriptCmdIndex = 0; $userCode = ""; $userCodeCalls = "\nswitch(funcIndex)\n{\n"; $selAwareCmdCount = 0; $selAwareCmds = ""; for ($i = 0; $i < $commands->GetCount(); $i++) { $cmd = $commands->GetItem($i); if (!$cmd->IsUsed()) { continue; } $tgtViewer = $cmd->GetTargetViewerType(); if (($tgtViewer == MgWebTargetViewerType::Dwf) != ($forDwf == true) && $tgtViewer != MgWebTargetViewerType::All) { continue; } $name = $cmd->GetName(); $action = $cmd->GetAction(); if ($action == MgWebActions::Search) { $cols = "var resCols" . $searchCmdIndex . " = new Array();\n"; if ($cmd->GetResultColumnCount() > 0) { for ($j = 0; $j < $cmd->GetResultColumnCount(); $j++) { $col = sprintf("resCols%d[%d] = new ResultColumn(\"%s\", \"%s\");\n", $searchCmdIndex, $j, StrEscape($cmd->GetColumnDisplayNameAt($j)), StrEscape($cmd->GetColumnPropertyNameAt($j))); $cols = $cols . $col; } } $cmdObjects = $cmdObjects . $cols; // declare a new search command object $cmdObject = sprintf("commands[%d] = new SearchCommand(\"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", resCols%d, \"%s\", %d, %d, \"%s\");\n", $i, StrEscape($name), StrEscape($cmd->GetLabel()), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetLayer(), StrEscape($cmd->GetPrompt()), $searchCmdIndex, StrEscape($cmd->GetFilter()), $cmd->GetMatchLimit(), $cmd->GetTarget(), $cmd->GetTargetName()); $searchCmdIndex++; } else { if ($action == MgWebActions::InvokeUrl) { // create the parameter objects $params = "var navParams" . $navCmdIndex . " = new Array();\n"; $layers = "var layers" . $navCmdIndex . " = new Array();\n"; if ($cmd->GetParameterCount() > 0) { for ($j = 0; $j < $cmd->GetParameterCount(); $j++) { $param = sprintf("navParams%d[%d] = new NavParam(\"%s\", \"%s\");\n", $navCmdIndex, $j, $cmd->GetParameterNameAt($j), $cmd->GetParameterValueAt($j)); $params = $params . $param; } } for ($j = 0; $j < $cmd->GetLayerCount(); $j++) { $layer = sprintf("layers%d[%d] = \"%s\";\n", $navCmdIndex, $j, $cmd->GetLayerNameAt($j)); $layers = $layers . $layer; } $cmdObjects = $cmdObjects . $params . $layers; if ($cmd->DisabledIfSelectionEmpty() || $cmd->GetLayerCount() > 0) { $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i); $selAwareCmdCount++; } // declare a new invokeurl command object $cmdObject = sprintf("commands[%d] = new InvokeUrlCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", navParams%d, %s, layers%d, %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $navCmdIndex, $cmd->DisabledIfSelectionEmpty() ? "true" : "false", $navCmdIndex, $cmd->GetTarget(), $cmd->GetTargetName()); $navCmdIndex++; } else { if ($action == MgWebActions::Buffer || $action == MgWebActions::SelectWithin || $action == MgWebActions::Measure || $action == MgWebActions::ViewOptions || $action == MgWebActions::GetPrintablePage) { if ($action == MgWebActions::Measure) { if ($measureCmdIndex != 0) { throw new Exception(GetLocalizedString("ALREADYINMEASURE", $locale)); } $measureCmdIndex = $i; } else { if ($action == MgWebActions::SelectWithin) { $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i); $selAwareCmdCount++; } } // declare a new ui target command object $cmdObject = sprintf("commands[%d] = new UiTargetCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetTarget(), $cmd->GetTargetName()); } else { if ($action == MgWebActions::Help) { // declare a new help command object $cmdObject = sprintf("commands[%d] = new HelpCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $cmd->GetTarget(), $cmd->GetTargetName()); } else { if ($action == MgWebActions::PrintMap) { // declare the print layouts $layouts = "var layouts" . $printCmdIndex . " = new Array();\n"; for ($j = 0; $j < $cmd->GetPrintLayoutCount(); $j++) { $layout = ""; $layout = sprintf("layouts%d[%d] = \"%s\";\n", $printCmdIndex, $j, $cmd->GetPrintLayoutAt($j)); $layouts = $layouts . $layout; } $cmdObjects = $cmdObjects . $layouts; // declare a new print command object $cmdObject = sprintf("commands[%d] = new PrintCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", layouts%d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $printCmdIndex); $printCmdIndex++; } else { if ($action == MgWebActions::InvokeScript) { // declare a new basic command object $cmdObject = sprintf("commands[%d] = new InvokeScriptCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $scriptCmdIndex); $userCode = $userCode . "\nfunction UserFunc" . $scriptCmdIndex . "()\n{\n" . $cmd->GetScriptCode() . "\n}\n"; $userCodeCalls = $userCodeCalls . sprintf("case %d: UserFunc%d(); break;\n", $scriptCmdIndex, $scriptCmdIndex); $scriptCmdIndex++; } else { // declare a new basic command object $cmdObject = sprintf("commands[%d] = new BasicCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\");\n", $i, $name, $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription())); } } } } } } $cmdObjects = $cmdObjects . $cmdObject; $cmds[$name] = $i; } $userCodeCalls = $userCodeCalls . "\n}\n"; //Declare toolbar items // $toolbarDef = DeclareUiItems($toolBar->GetWidgets(), "toolbarItems"); //Declare task items $taskListDef = DeclareUiItems($taskBar->GetTaskList(), "taskItems"); //Declare context menu items $ctxMenu = $webLayout->GetContextMenu(); if ($ctxMenu->IsVisible()) { $ctxMenuDef = DeclareUiItems($ctxMenu, "ctxMenuItems"); } else { $ctxMenuDef = ""; } //task items texts // $taskItemTexts = ""; $taskButtons = $taskBar->GetTaskButtons(); for ($i = 0; $i < 4; $i++) { $btn = $taskButtons->GetWidget($i); if ($i > 0) { $taskItemTexts = $taskItemTexts . ","; } $taskItemTexts = $taskItemTexts . '"' . StrEscape($btn->GetName()) . '",' . '"' . StrEscape($btn->GetTooltip()) . '",' . '"' . StrEscape($btn->GetDescription()) . '",' . '"' . StrEscape($btn->GetIconUrl()) . '",' . '"' . StrEscape($btn->GetDisabledIconUrl()) . '"'; } //transmit the session to the map pane if one was specified to this request if ($orgSessionId != "") { $sessionParam = "&SESSION=" . $orgSessionId; } else { $sessionParam = ""; } //load the frameset template and format it $frameset = ""; $viewerType = $forDwf ? "DWF" : "HTML"; if ($showTaskBar) { $frameSetTempl = file_get_contents("../viewerfiles/framesettaskbar.templ"); $frameset = sprintf($frameSetTempl, $statusbarHeight, $taskWidth, $toolbarHeight, $srcToolbar, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $vpath . "formframe.php", $taskbarHeight + 1, $srcTaskBar, $srcTaskFrame, $srcStatusbar); } else { $frameSetTempl = file_get_contents("../viewerfiles/framesetnotaskbar.templ"); $frameset = sprintf($frameSetTempl, $toolbarHeight, $statusbarHeight, $srcToolbar, $taskWidth, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $srcTaskFrame, $vpath . "formframe.php", $srcStatusbar); } $homePageUrl = urldecode($taskPaneUrl); if (strlen($homePageUrl) < 8 || strncasecmp($homePageUrl, "http://", 7) != 0) { $homePageUrl = $vpath . $homePageUrl; } //load the HTML template and format it // $templ = Localize(file_get_contents("../viewerfiles/mainframe.templ"), $locale, GetClientOS()); print sprintf($templ, $title, GetRootVirtualFolder() . "/mapagent/mapagent.fcgi", $enablePingServer ? 1 : 0, $site->GetSite()->GetSessionTimeout(), $locale, $showToolbar ? 1 : 0, $showStatusbar ? 1 : 0, $showTaskPane ? 1 : 0, $showTaskPane ? 0 : ($showTaskBar ? 1 : 0), $homePageUrl, $defHome ? "1" : "0", $webLayoutDefinition, $mapDef, $taskWidth, $center, $webLayout->GetScale(), StrEscape($title), $forDwf ? "1" : "0", $cmdObjects, $toolbarDef, $taskListDef, $ctxMenuDef, $userCode, $taskItemTexts, $selAwareCmds, $startupScriptCode, $vpath . "quickplotpanel.php", $vpath . "measureui.php", $vpath . "searchprompt.php", $vpath . "bufferui.php", $vpath . "selectwithinui.php", $userCodeCalls, $vpath . "viewoptions.php", $frameset); } catch (MgUserNotFoundException $e) { requestAuthentication(); } catch (MgAuthenticationFailedException $e) { requestAuthentication(); } catch (MgException $e) { // This should be a 500 error of some sort, but // in order to give a nice custom error message, it looks as // if we shortcut things by using a 200 status. $shortError = $e->GetExceptionMessage(); $longErrorMsg = EscapeForHtml($e->GetDetails()); header("HTTP/1.1 200 "); header('Content-Type: text/html; charset=utf-8'); header("Status: 200 {$shortError}"); echo "<html>\n<body>\n"; echo $longErrorMsg; echo "</body>\n</html>\n"; } catch (Exception $ne) { $errorMsg = EscapeForHtml($ne->GetMessage()); echo $errorMsg; } }
public $parentName; public $layerData; } $mapName = ""; $sessionId = ""; $summary = false; $layerCount = 0; $intermediateVar = 0; GetRequestParameters(); $updateType = -1; $output = "\nvar layerData = new Array();\n"; try { InitializeWebTier(); // connect to the site and get a resource service instance // $userInfo = new MgUserInformation(); $userInfo->SetMgSessionId($sessionId); $userInfo->SetClientIp(GetClientIp()); $userInfo->SetClientAgent(GetClientAgent()); $site = new MgSiteConnection(); $site->Open($userInfo); $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); //Load the map runtime state. // $map = new MgMap(); $map->Open($resourceSrvc, $mapName); $layerMap = null; $tree = BuildLayerTree($map, $resourceSrvc); if ($summary) { $updateType = 0; // return only the layer structure, that is mainly groups/layers/layer-ids. Do not parse layer definitions.
function EnumerateRoles2($paramSet) { try { $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"USER\""); $this->arrayParam["USER"] = $this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"LOGIN\""); $this->arrayParam['LOGIN'] = $this->unitTestParamVm->GetString("ParamValue") . ""; $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"PASSWORD\""); $this->arrayParam['PASSWORD'] = $this->unitTestParamVm->GetString("ParamValue") . ""; $userInfo = new MgUserInformation(); $userInfo->SetMgUsernamePassword($this->arrayParam['LOGIN'], $this->arrayParam['PASSWORD']); $userInfo->SetLocale("en"); $site2 = new MgSite(); $site2->Open($userInfo); $collection = $site2->EnumerateRoles($this->arrayParam['USER']); $site2->Close(); return new Result(Utils::MgStringCollectionToString($collection), "text/plain"); } catch (MgException $e) { return new Result(get_class($e), "text/plain"); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } }
// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // include 'common.php'; include 'constants.php'; $mapName = ""; $sessionId = ""; $inputSel = ""; $layers = null; $dwf = 0; GetRequestParameters(); try { InitializeWebTier(); $cred = new MgUserInformation($sessionId); $cred->SetClientIp(GetClientIp()); $cred->SetClientAgent(GetClientAgent()); //connect to the site and get an instance of each service used in this script // $site = new MgSiteConnection(); $site->Open($cred); $featureSrvc = $site->CreateService(MgServiceType::FeatureService); $renderingSrvc = $site->CreateService(MgServiceType::RenderingService); $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); //load the map runtime state // $map = new MgMap(); $map->Open($resourceSrvc, $mapName); $layers = explode(",", $layers); if (count($layers) > 0) {
} if (empty($adminPassword)) { throw new Exception($errPasswordMissing); } // Initialize web tier with the site configuration file. The config // file should be in the directory above as this script. $webConfigFile = __FILE__; $pos = strrpos($webConfigFile, '\\'); if ($pos == false) { $pos = strrpos($webConfigFile, '/'); } $relativeLocation = '../' . MgConfigProperties::DefaultConfigurationFilename; $webConfigFile = substr_replace($webConfigFile, $relativeLocation, $pos + 1); MgInitializeWebTier($webConfigFile); // Set up user info $userInfo = new MgUserInformation(); $userInfo->SetMgUsernamePassword($adminID, $adminPassword); $userInfo->SetLocale($locale); $clientAgent = GetClientAgent(); $clientIp = GetClientIp(); $userInfo->SetClientAgent($clientAgent); $userInfo->SetClientIp($clientIp); // Create a Site object and open the Site Server. $site = new MgSite(); $site->Open($userInfo); // Check that we have Administrator permission. $servers = $site->EnumerateServers(); // Determine the available site servers $numSites = $site->GetSiteServerCount(); if ($numSites == 1) { // Create session
function Login($username, $password) { $user = FALSE; $encryptedPassword = crypt($password, SALT); $result = $this->db->query('SELECT userid FROM users WHERE username = "******" and password = "******" and disabled = 0 and resetkey = ' . "''" . ';'); try { if ($result) { $aRow = $result->fetch(SQLITE_ASSOC); $user = $this->GetUser($aRow['userid']); } else { //user was logged in by the MapGuide server if we got to here, we //need to kick them out. global $sessionID; $user = new MgUserInformation("Anonymous", ""); $user->SetMgSessionId($sessionID); } } catch (MgException $e) { return "<Error>Login failed.</Error>"; } return $user; }
$geomName = $_GET['geomname']; $geomType = $_GET['geomtype']; $totalEntries = 0; $firstTime = true; $validSession = 1; $useBasicViewer = $_GET['viewer'] == 'basic'; $viewerRequest = '../schemareport/blank.php'; try { $thisFile = __FILE__; $pos = strrpos($thisFile, '\\'); if ($pos == false) { $pos = strrpos($thisFile, '/'); } $configFilePath = substr($thisFile, 0, $pos + 1) . "../webconfig.ini"; MgInitializeWebTier($configFilePath); $userInfo = new MgUserInformation($sessionId); $userInfo->SetClientIp(GetClientIp()); $userInfo->SetClientAgent(GetClientAgent()); $site = new MgSiteConnection(); $site->Open($userInfo); $featureSrvc = $site->CreateService(MgServiceType::FeatureService); $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); $featuresId = new MgResourceIdentifier($resName); $schemaName = substr(strrchr($schemaName, "/"), 1); $classDef = $featureSrvc->GetClassDefinition($featuresId, $schemaName, $className); $clsProps = $classDef->GetProperties(); $geomProp = $clsProps->GetItem($geomName); //TODO: Worse case scenario is no provider support for Count() or SpatialExtents() //In such cases, we should piggy-back off of the same raw-spun feature reader to compile the count and MBR //instead of having to raw-spin twice (once to get the count, another to get the MBR via EXTENT()) //
*/ /* //Point Rules $markSymbol = LayerDefinitionFactory::CreateMarkSymbol("", "", 5, 5, "FF800000"); $textSymbol = LayerDefinitionFactory::CreateTextSymbol("", "10", "FF808000"); $pointRule = LayerDefinitionFactory::CreatePointRule("TestPoint", "", $textSymbol, $markSymbol); $pointStyle = LayerDefinitionFactory::CreatePointTypeStyle($pointRule); $scaleRange = LayerDefinitionFactory::CreateScaleRange('0', '1000000000000', $pointStyle); */ //Create layer definition $layerDef = LayerDefinitionFactory::CreateLayerDefinition('Library://NewParcels.LayerDefinition', 'Parcels', 'SHPGEOM', $scaleRange); //Uncomment to check out the generated xml //file_put_contents('test.xml',$layerDef); $byteSource = new MgByteSource($layerDef, strlen($layerDef)); $byteReader = $byteSource->GetReader(); $cred = new MgUserInformation(); $cred->SetMgUsernamePassword('Anonymous', ''); $cred->SetClientIp(GetClientIp()); $cred->SetClientAgent(GetClientAgent()); $siteConn = new MgSiteConnection(); $siteConn->Open($cred); $svc = $siteConn->CreateService(MgServiceType::ResourceService); $resId = new MgResourceIdentifier('Library://Test/NewLayer.LayerDefinition'); try { $svc->SetResource($resId, $byteReader, null); } catch (MgException $e) { $errorMsg = EscapeForHtml($e->GetExceptionMessage()); echo $errorMsg; }
public function DestroySession($sessionId) { try { $siteConn = new MgSiteConnection(); $userInfo = new MgUserInformation($sessionId); $userInfo->SetClientAgent("MapGuide REST Extension"); $userInfo->SetClientIp($this->GetClientIp()); $siteConn->Open($userInfo); $site = $siteConn->GetSite(); $site->DestroySession($sessionId); } catch (MgException $ex) { $this->OnException($ex); } }
function LoadSessionVars() { global $webConfigFile; global $adminSession; global $selectedUser; global $selectedGroup; global $selectedRole; global $selectedServer; global $selectedService; global $selectedLog; global $selectedPackage; global $selectedMapping; global $packageLoadErrorMsg; global $packageMakeErrorMsg; global $packageLoadConfirmationMsg; global $packageMakeConfirmationMsg; global $confirmationMsg; global $userInfo; global $clientAgent; global $clientIp; global $site; global $autoRefresh; global $autoRefreshFrequency; global $limitRefresh; global $numRecsToRefresh; global $popups; try { if (!array_key_exists('webConfigFile', $_SESSION)) { // if the user attempts to access a php page without logging in, // webConfigFile does not exist on the first load throw new AuthenticationFailedException("webConfigFile does not exist"); } // Load the current vals of session vars. $webConfigFile = $_SESSION['webConfigFile']; $adminSession = $_SESSION['adminSession']; $selectedUser = $_SESSION['selectedUser']; $selectedGroup = $_SESSION['selectedGroup']; $selectedRole = $_SESSION['selectedRole']; $selectedServer = $_SESSION['selectedServer']; $selectedService = $_SESSION['selectedService']; $selectedLog = $_SESSION['selectedLog']; $selectedPackage = $_SESSION['selectedPackage']; $selectedMapping = $_SESSION['selectedMapping']; $packageLoadErrorMsg = $_SESSION['packageLoadErrorMsg']; $packageMakeErrorMsg = $_SESSION['packageMakeErrorMsg']; $packageLoadConfirmationMsg = $_SESSION['packageLoadConfirmationMsg']; $packageMakeConfirmationMsg = $_SESSION['packageMakeConfirmationMsg']; $confirmationMsg = $_SESSION['confirmationMsg']; $clientAgent = $_SESSION['clientAgent']; $clientIp = $_SESSION['clientIp']; $autoRefresh = $_SESSION['autoRefresh']; $autoRefreshFrequency = $_SESSION['autoRefreshFrequency']; $limitRefresh = $_SESSION['limitRefresh']; $numRecsToRefresh = $_SESSION['numRecsToRefresh']; $popups = $_SESSION['popups']; if (empty($webConfigFile)) { // if the user attempts to access a php page without logging in, // webConfigFile is empty (on all loads after the first one) throw new AuthenticationFailedException("webConfigFile is empty"); } // Initialize web tier with the site configuration file. MgInitializeWebTier($webConfigFile); // Set up user info $userInfo = new MgUserInformation(); $userInfo->SetMgSessionId($adminSession); $userInfo->SetClientAgent($clientAgent); $userInfo->SetClientIp($clientIp); // Create a Site object and open the Site Server. $site = new MgSite(); $site->Open($userInfo); } catch (AuthenticationFailedException $e) { LogoutWithAuthenticationFailedException(); } catch (Exception $e) { LogoutWithFatalException(); } }
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --> <head> <title>PHP Test</title> </head> <body> <?php include 'common.php'; echo "<b>Server Admin Service Tests</b><p>"; // Initialize web tier with the site configuration file. InitializeWebTier(); $cred = new MgUserInformation(); $cred->SetMgUsernamePassword("Administrator", "admin"); $cred->SetLocale(GetDefaultLocale()); $cred->SetClientIp(GetClientIp()); $cred->SetClientAgent(GetClientAgent()); $serverAdmin = new MgServerAdmin(); $serverAdmin->Open("localhost", $cred); $operation = $_GET['OPERATION']; //Get all information properties $infoProp = $serverAdmin->GetInformationProperties(); try { switch ($operation) { case "ONLINE": $serverAdmin->BringOnline(); if ($serverAdmin->IsOnline()) { echo "Server online<p>";