function CloudUserSetPassword($method_parameters) { global $event; global $CloudDir; $parameter_array = explode(',', $method_parameters); $mode = $parameter_array[0]; $username = $parameter_array[1]; $password = $parameter_array[2]; $clouduser_name = $parameter_array[3]; $clouduser_password = $parameter_array[4]; // check all user input for ($i = 0; $i <= 5; $i++) { if (!$this->check_param($parameter_array[$i])) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Not allowing user-intput with special-characters : {$parameter_array[$i]}", "", "", 0, 0, 0); return 1; } } // check parameter count $parameter_count = count($parameter_array); if ($parameter_count != 5) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Wrong parameter count {$parameter_count} ! Exiting.", "", "", 0, 0, 0); return 1; } // check authentication if (!$this->check_user($mode, $username, $password)) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "User authentication failed (mode {$mode})", "", "", 0, 0, 0); return 1; } $cl_user = new clouduser(); if ($cl_user->is_name_free($clouduser_name)) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User name {$clouduser_name} does not exists in the Cloud !", "", "", 0, 0, 0); return 1; } // min 6 chars long $plen = strlen($clouduser_password); if ($plen < 6) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud password must be at least 6 characters long !", "", "", 0, 0, 0); return 1; } // check that in user mode the username is the same as the cloud_username switch ($mode) { case 'user': if (strcmp($username, $clouduser_name)) { $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 2, "cloud-soap-server.php", "Cloud User {$username} is trying to gather the Limits informations of Cloud User {$clouduser_name} !", "", "", 0, 0, 0); return 1; } break; } // set user details $event->log("cloudsoap->CloudUserSetPassword", $_SERVER['REQUEST_TIME'], 5, "cloud-soap-server.php", "Updateing password for Cloud Users {$clouduser_name}", "", "", 0, 0, 0); $cl_user->get_instance_by_name($clouduser_name); $cloud_user_array = array(); $cloud_user_array['cu_password'] = $clouduser_password; $cl_user->update($cl_user->id, $cloud_user_array); // remove old user $openqrm_server_command = "htpasswd -D {$CloudDir}/user/.htpasswd {$clouduser_name}"; $output = shell_exec($openqrm_server_command); // create new + new password $openqrm_server_command = "htpasswd -b {$CloudDir}/user/.htpasswd {$clouduser_name} {$clouduser_password}"; $output = shell_exec($openqrm_server_command); return 0; }
function __construct() { // handle timezone needed since php 5.3 if (function_exists('ini_get')) { if (ini_get('date.timezone') === '') { date_default_timezone_set('Europe/Berlin'); } } $this->rootdir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base'; $this->portaldir = $_SERVER["DOCUMENT_ROOT"] . '/cloud-portal'; $this->tpldir = $this->portaldir . '/user/tpl/'; $this->langdir = $this->portaldir . '/user/lang/'; require_once $this->rootdir . '/class/file.handler.class.php'; require_once $this->rootdir . '/class/htmlobjects/htmlobject.class.php'; require_once $this->rootdir . '/class/openqrm.htmlobjects.class.php'; $html = new openqrm_htmlobject(); $file = new file_handler(); $this->response = $html->response(); // handle user $user = ''; if (isset($_SERVER['PHP_AUTH_USER'])) { require_once $this->rootdir . '/plugins/cloud/class/clouduser.class.php'; $user = new clouduser($_SERVER['PHP_AUTH_USER']); $user->get_instance_by_name($_SERVER['PHP_AUTH_USER']); // handle user lang $lang = $this->response->html->request()->get('langselect'); if ($lang !== '') { $user->update($user->id, array('cu_lang' => $lang)); $user->get_instance_by_name($_SERVER['PHP_AUTH_USER']); } } // if openQRM is unconfigured, set openqrm empty if ($file->exists($this->rootdir . '/unconfigured')) { $this->openqrm = ''; $this->webdir = $html->thisdir; $this->baseurl = $html->thisurl; } else { require_once $this->rootdir . '/class/openqrm.class.php'; $this->openqrm = new openqrm($file, $user, $html->response()); $this->webdir = $this->openqrm->get('webdir'); $this->baseurl = $this->openqrm->get('baseurl'); } // translate if ($user !== '') { $lang = $user->lang; } else { $lang = $this->response->html->request()->get('langselect'); } $html->lang = $this->__translate($lang, $html->lang, $this->langdir, 'htmlobjects.ini'); $file->lang = $this->__translate($lang, $file->lang, $this->langdir, 'file.handler.ini'); require_once $this->rootdir . '/include/requestfilter.inc.php'; $request = $html->request(); $request->filter = $requestfilter; $this->file = $file; $this->baseurl = '/cloud-portal/'; // templating default or custom $tpl = $this->portaldir . "/user/tpl/index.default.tpl.php"; if ($this->file->exists($this->portaldir . "/user/tpl/index.tpl.php")) { $tpl = $this->portaldir . "/user/tpl/index.tpl.php"; } $this->tpl = $tpl; }