function resetDefaultMenu($uuid)
{
$ret = xmlrpc_resetComputerBootMenu($uuid);
if (!isXMLRPCError() && $ret) {
new NotifyWidgetSuccess(sprintf(_T("Default menu has been successfully restored.", "imaging")));
}
}
/**
* Make a XML-RPC call
* If the global variable $errorStatus is not zero, the XML-RPC call is not
* done, and this function returns nothing.
*
* @param $method name of the method
* @param $params array with param
* @return the XML-RPC call result
*/
function xmlCall($method, $params = null)
{
global $errorStatus;
global $errorDesc;
global $conf;
if (isXMLRPCError()) {
// Don't do a XML-RPC call if a previous one failed
return;
}
/*
Set defaut login/pass if not set.
The credentials are used to authenticate the web interface to the XML-RPC
server.
*/
if (!isset($conf["global"]["login"])) {
$conf["global"]["login"] = "mmc";
$conf["global"]["password"] = "s3cr3t";
}
$output_options = array("output_type" => "xml", "verbosity" => "pretty", "escaping" => array("markup"), "version" => "xmlrpc", "encoding" => "UTF-8");
$request = xmlrpc_encode_request($method, $params, $output_options);
/* We build the HTTP POST that will be sent */
$host = $_SESSION["XMLRPC_agent"]["host"] . ":" . $_SESSION["XMLRPC_agent"]["port"];
$url = "/";
$httpQuery = "POST " . $url . " HTTP/1.0\r\n";
$httpQuery .= "User-Agent: MMC web interface\r\n";
$httpQuery .= "Host: " . $host . "\r\n";
$httpQuery .= "Content-Type: text/xml\r\n";
$httpQuery .= "Content-Length: " . strlen($request) . "\r\n";
/* Don't set the RPC session cookie if the user is on the login page */
if ($method == "base.ldapAuth" || $method == "base.tokenAuthenticate") {
unset($_SESSION["RPCSESSION"]);
$httpQuery .= "X-Browser-IP: " . $_SERVER["REMOTE_ADDR"] . "\r\n";
$httpQuery .= "X-Browser-HOSTNAME: " . gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\r\n";
} else {
$httpQuery .= "Cookie: " . $_SESSION["RPCSESSION"] . "\r\n";
}
$httpQuery .= "Authorization: Basic " . base64_encode($conf["global"]["login"] . ":" . $conf["global"]["password"]) . "\r\n\r\n";
$httpQuery .= $request;
$sock = null;
/* Connect to the XML-RPC server */
if ($_SESSION["XMLRPC_agent"]["scheme"] == "https") {
$prot = "ssl://";
} else {
$prot = "";
}
list($sock, $errNo, $errString) = openSocket($prot, $conf);
if (!$sock) {
/* Connection failure */
$errObj = new ErrorHandlingItem('');
$errObj->setMsg(_("Can't connect to MMC agent"));
$errObj->setAdvice(_("MMC agent seems to be down or not correctly configured.") . '<br/> Error: ' . $errNo . ' - ' . $errString);
$errObj->setTraceBackDisplay(false);
$errObj->setSize(400);
$errObj->process('');
$errorStatus = 1;
return FALSE;
}
/* Send the HTTP POST */
if (!fwrite($sock, $httpQuery, strlen($httpQuery))) {
/* Failure */
$errObj = new ErrorHandlingItem('');
$errObj->setMsg(_("Can't send XML-RPC request to MMC agent"));
$errObj->setAdvice(_("MMC agent seems to be not correctly configured."));
$errObj->setTraceBackDisplay(false);
$errObj->setSize(400);
$errObj->process('');
$errorStatus = 1;
return FALSE;
}
fflush($sock);
/* Get the response from the server */
$xmlResponse = '';
while (!feof($sock)) {
$ret = fread($sock, 8192);
$info = stream_get_meta_data($sock);
if ($info['timed_out']) {
$errObj = new ErrorHandlingItem('');
$errObj->setMsg(_('MMC agent communication problem'));
$errObj->setAdvice(_('Timeout when reading data from the MMC agent. Please check network connectivity and server load.'));
$errObj->setTraceBackDisplay(false);
$errObj->setSize(400);
$errObj->process('');
$errorStatus = 1;
return FALSE;
}
if ($ret === False) {
$errObj = new ErrorHandlingItem('');
$errObj->setMsg(_("Error while reading MMC agent XML-RPC response."));
$errObj->setAdvice(_("Please check network connectivity."));
$errObj->setTraceBackDisplay(false);
$errObj->setSize(400);
//.........这里部分代码省略.........
# synchronization of locations
global $SYNCHROSTATE_UNKNOWN;
global $SYNCHROSTATE_TODO;
global $SYNCHROSTATE_SYNCHRO;
global $SYNCHROSTATE_RUNNING;
global $SYNCHROSTATE_INIT_ERROR;
$location = getCurrentLocation();
if (isset($_POST['bsync'])) {
$params['bsync'] = '1';
$ret = xmlrpc_synchroLocation($_POST['location_uuid']);
// goto images list
if ((is_array($ret) and $ret[0] or !is_array($ret) and $ret) and !isXMLRPCError()) {
/* insert notification code here if needed */
} elseif (!$ret[0] and !isXMLRPCError()) {
new NotifyWidgetFailure(sprintf(_T("Boot menu generation failed for package server: %s<br /><br />Check /var/log/mmc/pulse2-package-server.log", "imaging"), implode(', ', $ret[1])));
} elseif (isXMLRPCError()) {
new NotifyWidgetFailure(sprintf(_T("Boot menu generation failed for package server: %s<br /><br />Check /var/log/mmc/pulse2-package-server.log", "imaging"), implode(', ', $ret[1])));
}
}
# needed in the case we have to go back to the good list.
$params['from'] = $_GET['action'];
$params['module'] = $_GET['module'];
$params['submod'] = $_GET['submod'];
$params['action'] = $_GET['action'];
if (displayLocalisationBar()) {
$location = getCurrentLocation();
$ajax = new AjaxLocation("modules/imaging/manage/{$page}.php", "container_{$page}", "location", $params);
list($list, $values) = getEntitiesSelectableElements();
$ajax->setElements($list);
$ajax->setElementsVal($values);
if ($location) {
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MMC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MMC; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once "modules/pkgs/includes/xmlrpc.php";
if (isset($_POST["bconfirm"])) {
activateAppstreamFlow($_POST['id'], $_POST['package_name'], $_POST['package_label'], $_POST['duration']);
if (!isXMLRPCError() and $ret != -1) {
new NotifyWidgetSuccess(_T("The stream has been added successfully. You will receive the latest updates of this stream directly in your package list.", "pkgs"));
}
if ($ret == -1) {
new NotifyWidgetFailure(_T("Unable to add stream.", "pkgs"));
}
header("Location: " . urlStrRedirect("pkgs/pkgs/appstreamSettings", array()));
exit;
} else {
$id = $_GET['id'];
$package_name = $_GET['package_name'];
$package_label = $_GET['package_label'];
$duration = $_GET['duration'];
$f = new PopupForm(_T("Activate this Appstream stream?"));
$hidden = new HiddenTpl("id");
$f->add($hidden, array("value" => $id, "hide" => True));
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MMC; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require "modules/samba4/includes/machines-xmlrpc.inc.php";
if (isset($_GET["machine"])) {
$machine = urldecode($_GET["machine"]);
}
if (isset($_POST["machine"])) {
$machine = $_POST["machine"];
}
if (isset($_POST["bdeleletemachine"])) {
$deleteActionSuccess = deleteMachine($machine);
if (!isXMLRPCError() and $deleteActionSuccess) {
$computerDeletedMessage = sprintf(_T("Computer <strong>%s</strong> deleted.", "samba4"), $machine);
new NotifyWidgetSuccess($computerDeletedMessage);
} else {
$computerDeletedMessage = sprintf(_T("There has been a problem while deleting <strong>%s</strong> computer.", "samba4"), $machine);
new NotifyWidgetFailure($computerDeletedMessage);
}
header("location: " . urlStrRedirect('samba4/machines/index'));
exit;
} else {
$form = new PopupForm(_T("Delete a computer", "samba4"));
$form->addText(sprintf(_T("You will delete the %s computer", "samba4"), "<strong>{$machine}</strong>"));
$form->addValidateButton("bdeleletemachine");
$form->addCancelButton("bback");
$form->display();
}
function _displaySuccessMessage($success, $message)
{
if (!isXMLRPCError() and $success) {
new NotifyWidgetSuccess($message);
} else {
global $errorStatus;
$errorStatus = 0;
}
}
开发者ID:psyray,项目名称:mmc,代码行数:9,代码来源:edit.php
示例16: _samba_changeUser
/**
* Function called for changing user attributes
* @param $FH FormHandler of the page
* @param $mode add or edit mode
*/
function _samba_changeUser($FH, $mode)
{
global $error;
global $result;
# check users profiles setup
$globalProfiles = xmlCall("samba.isProfiles");
# Already existing SAMBA user
if (hasSmbAttr($FH->getPostValue("uid"))) {
# Remove atrributes
if (!$FH->getPostValue("isSamba")) {
rmSmbAttr($FH->getPostValue("uid"));
$result .= _T("Samba attributes deleted.", "samba") . "<br />";
} else {
# Remove passwords from the $_POST array coming from the add/edit user page
# because we don't want to send them again via RPC.
$FH->delPostValue("pass");
$FH->delPostValue("confpass");
// Format samba attributes
if ($FH->isUpdated("sambaPwdMustChange")) {
if ($FH->getValue("sambaPwdMustChange") == "on") {
// force user to change password
$FH->setValue("sambaPwdMustChange", "0");
$FH->setValue("sambaPwdLastSet", "0");
} else {
$FH->setValue("sambaPwdMustChange", "");
$FH->setValue("sambaPwdLastSet", (string) time());
}
}
// account expiration
if ($FH->isUpdated("sambaKickoffTime")) {
$datetime = $FH->getValue("sambaKickoffTime");
// 2010-09-23 18:32:00
if (strlen($datetime) == 19) {
$timestamp = mktime(substr($datetime, -8, 2), substr($datetime, -5, 2), substr($datetime, -2, 2), substr($datetime, 5, 2), substr($datetime, 8, 2), substr($datetime, 0, 4));
$FH->setValue("sambaKickoffTime", "{$timestamp}");
} else {
$FH->setValue("sambaKickoffTime", "");
}
}
// Network profile path
if ($FH->isUpdated("sambaProfilePath") && !$globalProfiles) {
$FH->setValue("sambaProfilePath", $FH->getPostValue("sambaProfilePath"));
}
if (!$FH->getPostValue("hasProfile") && $FH->getPostValue("old_hasProfile") == "on") {
$FH->setValue("sambaProfilePath", "");
}
// change attributes
changeSmbAttr($FH->getPostValue("uid"), $FH->getValues());
if (isEnabledUser($FH->getPostValue("uid"))) {
if ($FH->getPostValue('isSmbDesactive')) {
smbDisableUser($FH->getPostValue("uid"));
$result .= _T("Samba account disabled.", "samba") . "<br />";
}
} else {
if (!$FH->getPostValue('isSmbDesactive')) {
smbEnableUser($FH->getPostValue("uid"));
$result .= _T("Samba account enabled.", "samba") . "<br />";
}
}
if (isLockedUser($FH->getPostValue("uid"))) {
if (!$FH->getPostValue('isSmbLocked')) {
smbUnlockUser($FH->getPostValue("uid"));
}
} else {
if ($FH->getPostValue('isSmbLocked')) {
smbLockUser($FH->getPostValue("uid"));
}
}
}
} else {
//if not have smb attributes
if ($FH->getPostValue("isSamba")) {
# Add SAMBA attributes
addSmbAttr($FH->getPostValue("uid"), $FH->getPostValue("pass"));
if (!isXMLRPCError()) {
// Format samba attributes
if ($FH->getPostValue("sambaPwdMustChange") == "on") {
$FH->setPostValue("sambaPwdMustChange", "0");
$FH->setPostValue("sambaPwdLastSet", "0");
} else {
$FH->setPostValue("sambaPwdMustChange", "");
}
// Account expiration
if ($FH->isUpdated("sambaKickoffTime")) {
$datetime = $FH->getValue("sambaKickoffTime");
// 2010-09-23 18:32:00
if (strlen($datetime) == 19) {
$timestamp = mktime(substr($datetime, -8, 2), substr($datetime, -5, 2), substr($datetime, -2, 2), substr($datetime, 5, 2), substr($datetime, 8, 2), substr($datetime, 0, 4));
$FH->setPostValue("sambaKickoffTime", "{$timestamp}");
} else {
$FH->setPostValue("sambaKickoffTime", "");
}
}
// Network profile
// Clear profile path if global profiles are on
//.........这里部分代码省略.........
function create_group(&$error, $group)
{
if ($group == "") {
$error = "Groupe nul";
return;
}
if (in_array($group, get_groups($error))) {
$error = sprintf(_("Group %s already exist"), $group);
return;
}
$ret = xmlCall("base.createGroup", $group);
if (in_array("samba", $_SESSION["supportModList"])) {
// FIXME: should be a choice made by the user
// Samba plugin is enabled, so we make this group a Samba group,
// but only if we are a PDC.
$pdc = xmlCall("samba.isPdc", null);
if ($pdc) {
xmlCall("samba.makeSambaGroup", array($group));
}
}
if (!isXMLRPCError()) {
return sprintf(_("Group %s created"), $group);
} else {
return;
}
}
header("Location: " . urlStrRedirect("mail/domains/index"));
exit;
}
} else {
if (isset($_POST["bedit"]) || isset($_POST["breset"])) {
setVDomainDescription($domainname, $description);
if (strlen($domainquota)) {
setVDomainQuota($domainname, $domainquota);
}
$result = _T("The mail domain has been modified.", "mail") . "<br />";
if (isset($_POST["breset"])) {
resetUsersVDomainQuota($domainname);
$result .= _T(" The quota of all users of this mail domain have been reset.") . "<br />";
}
// Display result message
if ($result && !isXMLRPCError()) {
new NotifyWidgetSuccess($result);
}
}
}
}
$p = new PageGenerator($title);
$p->setSideMenu($sidemenu);
$p->display();
$f = new ValidatingForm();
$f->push(new Table());
if ($mode == "add") {
$domainTpl = new DomainInputTpl("domainname");
} else {
$domainTpl = new HiddenTpl("domainname");
}
开发者ID:sebastiendu,项目名称:mmc,代码行数:31,代码来源:edit.php
示例19: array
$cbx = array($random_dir);
} else {
if ($_POST['package-method'] == "package") {
$cbx = array();
foreach ($_POST as $post => $v) {
if (preg_match("/cbx_/", $post) > 0) {
$cbx[] = preg_replace("/cbx_/", "", $post);
}
}
if (isset($_POST['rdo_files'])) {
$cbx[] = $_POST['rdo_files'];
}
}
}
$ret = associatePackages($p_api_id, $pid, $cbx, $level);
if (!isXMLRPCError() and is_array($ret)) {
if ($ret[0]) {
$explain = '';
if (count($ret) > 1) {
$explain = sprintf(" : <br/>%s", implode("<br/>", $ret[1]));
}
new NotifyWidgetSuccess(sprintf(_T("Files successfully associated with package <b>%s (%s)</b>%s", "pkgs"), $plabel, $pversion, $explain));
header("Location: " . urlStrRedirect("pkgs/pkgs/index", array('location' => base64_encode($p_api_id))));
exit;
} else {
$reason = '';
if (count($ret) > 1) {
$reason = sprintf(" : <br/>%s", $ret[1]);
}
new NotifyWidgetFailure(sprintf(_T("Failed to associate files%s", "pkgs"), $reason));
}
请发表评论