Exemplo n.º 1
0
//
//  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
//
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<?php 
include 'utilityfunctions.php';
// Initialize a PHP session and register a variable to hold the
// Server session id, then initialize the Web Extensions,
// and connect to the Server, and create a session.
MgInitializeWebTier($configFilePath);
$site = new MgSite();
$site->Open(new MgUserInformation('Anonymous', ''));
$sessionId = $site->CreateSession();
$webLayout = "Library://Samples/Sheboygan/Layouts/SheboyganPhp.WebLayout";
?>

<html>

<head>
    <title>Viewer Sample Application</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>

<frameset rows="50,*" frameborder="NO" border="0" framespacing="0">
    <frame src="title.html?AppName=AJAX" name="TitleFrame" scrolling="NO" noresize>
    <frame src="../mapviewerphp/ajaxviewer.php?SESSION=<?php 
Exemplo n.º 2
0
            // Create session
            $adminSession = $site->CreateSession();
            // Save session variables
            SaveSessionVars();
            // Success - switch to ServerManagement page.
            header('Location:  servermanagement.php?' . strip_tags(SID));
            exit;
        } else {
            $siteInfo = GetSiteServerSelection($serverSelectionID);
            if ($siteInfo != NULL) {
                // Close the existing site connection
                if ($site != NULL) {
                    $site->Close();
                }
                // Determine the selected site
                $site = new MgSite();
                // Create a connection to the selected site
                $site->Open($userInfo, $siteInfo);
                // Create a session
                $adminSession = $site->CreateSession();
                $userInfo->SetMgSessionId($adminSession);
                // Save the session variables. All requests will now be directed to
                // our selected server since it hosts the current session.
                SaveSessionVars();
                header('Location:  servermanagement.php?' . strip_tags(SID));
                exit;
            }
        }
    }
} catch (MgConnectionFailedException $e) {
    $errorMsg = $errConnectionFailed;
Exemplo n.º 3
0
 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");
     }
 }
Exemplo n.º 4
0
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  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
-->
<?php 
require_once '../common.php';
try {
    // Initialize the web extensions,
    MgInitializeWebTier($webconfigFilePath);
    // Connect to the site server and create a session
    $userInfo = new MgUserInformation("Administrator", "admin");
    $site = new MgSite();
    $site->Open($userInfo);
} catch (MgException $e) {
    echo "Could not connect to the MapGuide site server. Please contact the MapGuide site administrator.";
    die;
}
try {
    $sessionId = $site->CreateSession();
    // Define some constants
    $webLayout = "Library://Samples/DevGuidePHP/modifying_maps_and_layers.WebLayout";
    $title = "Modifying Maps and Layers";
} catch (MgException $e) {
    echo "ERROR: " . $e->GetExceptionMessage("eng") . "\n";
    echo $e->GetStackTrace("eng") . "\n";
}
?>
Exemplo n.º 5
0
function SetupTestData()
{
    global $adminUser;
    global $adminPass;
    global $user1User;
    global $user1Pass;
    global $user2User;
    global $user2Pass;
    global $userGroup;
    $webConfigPath = dirname(__FILE__) . "/../../webconfig.ini";
    MgInitializeWebTier($webConfigPath);
    $mgp = dirname(__FILE__) . "/data/Sheboygan.mgp";
    if (!file_exists($mgp)) {
        echo "Please put Sheboygan.mgp into the /data directory before running this test suite";
        die;
    }
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_anonymous/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_anonymous/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_anonymous.json", dirname(__FILE__) . "/../conf/data/test_anonymous/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_author/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_author/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_author.json", dirname(__FILE__) . "/../conf/data/test_author/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_administrator/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_administrator/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_administrator.json", dirname(__FILE__) . "/../conf/data/test_administrator/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_wfsuser/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_wfsuser/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_wfsuser.json", dirname(__FILE__) . "/../conf/data/test_wfsuser/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_wmsuser/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_wmsuser/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_wmsuser.json", dirname(__FILE__) . "/../conf/data/test_wmsuser/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_group/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_group/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_group.json", dirname(__FILE__) . "/../conf/data/test_group/restcfg.json");
    if (!is_dir(dirname(__FILE__) . "/../conf/data/test_mixed/")) {
        mkdir(dirname(__FILE__) . "/../conf/data/test_mixed/");
    }
    copy(dirname(__FILE__) . "/data/restcfg_mixed.json", dirname(__FILE__) . "/../conf/data/test_mixed/restcfg.json");
    $source = new MgByteSource($mgp);
    $br = $source->GetReader();
    $siteConn = new MgSiteConnection();
    $userInfo = new MgUserInformation($adminUser, $adminPass);
    $siteConn->Open($userInfo);
    $site = new MgSite();
    $site->Open($userInfo);
    //Set up any required users
    try {
        $site->AddGroup($userGroup, "Group for mapguide-rest test suite users");
    } catch (MgException $ex) {
    }
    try {
        $site->AddUser($user1User, $user1User, $user1Pass, "Test user for mapguide-rest test suite");
    } catch (MgException $ex) {
    }
    try {
        $site->AddUser($user2User, $user2User, $user2Pass, "Test user for mapguide-rest test suite");
    } catch (MgException $ex) {
    }
    try {
        $groups = new MgStringCollection();
        $users = new MgStringCollection();
        $groups->Add($userGroup);
        $users->Add($user1User);
        $users->Add($user2User);
        $site->GrantGroupMembershipsToUsers($groups, $users);
    } catch (MgException $ex) {
    }
    $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
    $resSvc->ApplyResourcePackage($br);
    $srcId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
    $dstId = new MgResourceIdentifier("Library://RestUnitTests/Parcels.FeatureSource");
    $resSvc->CopyResource($srcId, $dstId, true);
    $bsWriteable = new MgByteSource(dirname(__FILE__) . "/data/Parcels_Writeable.FeatureSource.xml");
    $brWriteable = $bsWriteable->GetReader();
    $resSvc->SetResource($dstId, $brWriteable, null);
    $rdsdfsource = new MgByteSource(dirname(__FILE__) . "/data/RedlineLayer.sdf");
    $rdsdfrdr = $rdsdfsource->GetReader();
    $resId = new MgResourceIdentifier("Library://RestUnitTests/RedlineLayer.FeatureSource");
    $rdXml = '<?xml version="1.0"?><FeatureSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="FeatureSource-1.0.0.xsd"><Provider>OSGeo.SDF</Provider><Parameter><Name>File</Name><Value>%MG_DATA_FILE_PATH%RedlineLayer.sdf</Value></Parameter></FeatureSource>';
    $rdXmlSource = new MgByteSource($rdXml, strlen($rdXml));
    $rdXmlRdr = $rdXmlSource->GetReader();
    $resSvc->SetResource($resId, $rdXmlRdr, null);
    $resSvc->SetResourceData($resId, "RedlineLayer.sdf", MgResourceDataType::File, $rdsdfrdr);
}
Exemplo n.º 6
0
$viewerVersion = VIEWER_VERSION;
$serverVersion = "##Unknown";
$sessionId = "";
$locale = "";
SetLocalizedFilesPath(GetLocalizationPath());
GetRequestParameters();
try {
    // Initialize web tier with the site configuration file.
    InitializeWebTier();
    // Set up user info
    $userInfo = new MgUserInformation();
    $userInfo->SetMgSessionId($sessionId);
    $userInfo->SetClientIp(GetClientIp());
    $userInfo->SetClientAgent(GetClientAgent());
    // Create a Site object and open the Site Server.
    $site = new MgSite();
    $site->Open($userInfo);
    $serverAdmin = new MgServerAdmin();
    $serverAdmin->Open($userInfo);
    $infoProps = $serverAdmin->GetInformationProperties();
    $versionProp = $infoProps->GetItem(MgServerInformationProperties::ServerVersion);
    $serverVersion = $versionProp->GetValue();
} catch (MgException $e) {
} catch (Exception $e) {
}
$templ = Localize(file_get_contents("../viewerfiles/ajaxviewerabout.templ"), $locale, GetClientOS());
printf($templ, $titleBar, $titleBar, $serverTitle, $serverVersion, $viewerTitle, $viewerVersion);
function GetParameters($params)
{
    global $sessionId, $locale;
    $sessionId = ValidateSessionId(GetParameter($params, 'SESSION'));
Exemplo n.º 7
0
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();
    }
}
Exemplo n.º 8
0
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
try {
    include 'resizableadmin.php';
    LoadSessionVars();
    // Register this popup
    SavePopup('AdminAboutBox');
    // Define Local values
    $pageTitle = "About";
    $serverVersion = "?.?";
    $appVersion = SITE_ADMINISTRATOR_VERSION;
    $errorMsg = "";
    // Get Server
    $selectedServerID = "Server";
    $site = new MgSite();
    $site->Open($userInfo);
    $siteServerAddress = $site->GetCurrentSiteAddress();
    GetServerSelection($selectedServerID, $selectedServer);
    $serverRec = GetDataForServer($selectedServer);
    if ($serverRec == NULL) {
        throw new Exception(sprintf($errNotFound, $selectedServer));
    }
    if (!$serverRec->poweredUp) {
        throw new Exception(sprintf($errServerIsDown, $selectedServer));
    }
    $serverVersion = $serverRec->version;
} catch (MgException $e) {
    $errorMsg = preg_replace("/%20/", " ", $errFatalError);
} catch (Exception $e) {
    $errorMsg = $e->getMessage();