set_title($this->lang->mc); if (!isset($this->get['s'])) { $this->get['s'] = null; } if ($this->get['s'] == 'new') { $this->tree($this->lang->mc_add); if (!isset($this->post['submit'])) { $selectGroups = $this->htmlwidgets->select_groups(USER_MEMBER); $selectLangs = $this->htmlwidgets->select_langs($this->sets['default_lang'], '..'); return eval($this->template('ADMIN_USER_ADD')); } if (!isset($this->post['name']) || empty($this->post['name'])) { return $this->message($this->lang->mc_add, $this->lang->mc_user_name_required); } if (!isset($this->post['email']) || empty($this->post['email'])) { return $this->message($this->lang->mc_add, $this->lang->mc_user_email_required); } if ($this->db->fetch("SELECT user_id FROM users WHERE user_name='%s' LIMIT 1", $this->post['name'])) { return $this->message($this->lang->mc_add, sprintf($this->lang->mc_user_name_exists, $this->post['name'])); } $name = $this->post['name']; $email = $this->post['email']; $group = $this->post['group']; $lang = $this->post['lang']; $newpass = $this->generate_pass(8); $this->db->query("INSERT INTO users (user_name, user_email, user_password, user_group, user_language, user_created) VALUES( '%s', '%s', '%s', %d, '%s', %d )", $name, $email, md5($newpass), $group, $lang, $this->time ); $this->sets['users'] += 1; $this->write_sets(); $mailer = new $this->modules['mailer']($this->sets['admin_incoming'], $this->sets['admin_outgoing'], 'PDNS-Admin', false); $message = "A new PDNS-Admin account has been set up for you.\n\n"; $message .= "Your password has been set to:\n$newpass\n\n"; $message .= "You may log into your account here:\n\n{$this->sets['site_url']}{$this->mainfile}?a=login"; $mailer->setSubject('PDNS-Admin - New account setup'); $mailer->setMessage($message); $mailer->setRecipient($email); $mailer->setServer($this->sets['mailserver']); $mailer->doSend(); return $this->message($this->lang->mc_add, $this->lang->mc_user_new); } $this->tree($this->lang->mc, "$this->self?a=user_control&s=profile"); if (!isset($this->get['id'])) { if (!isset($this->post['username'])) { return $this->message($this->lang->mc, "
{$this->lang->mc_find}:

"); } else { $query = $this->db->query("SELECT user_id, user_name FROM users WHERE user_name LIKE '%%%s%%' LIMIT 250", $this->post['username']); if (!$this->db->num_rows($query)) { return $this->message($this->lang->mc, "{$this->lang->mc_not_found} \"{$this->post['username']}\""); } $ret = null; if ($this->get['s'] == 'profile') { $link = 'a=user_control&s=profile'; } elseif ($this->get['s'] == 'perms') { $link = 'a=perms&s=user'; } else { $link = 'a=user_control&s=delete'; } while ($user = $this->db->nqfetch($query)) { $ret .= "{$user['user_name']}
"; } return $this->message($this->lang->mc, "{$this->lang->mc_found}

$ret"); } } $this->get['id'] = intval($this->get['id']); switch ($this->get['s']) { case 'delete': $this->tree($this->lang->mc_delete); $this->get['id'] = intval($this->get['id']); if ($this->get['id'] == USER_GUEST_UID) { return $this->message($this->lang->mc_delete, $this->lang->mc_guest_needed); } if (!isset($this->get['confirm'])) { $user = $this->db->fetch('SELECT user_name FROM users WHERE user_id=%d', $this->get['id']); return $this->message($this->lang->mc_delete, "{$this->lang->mc_confirm} {$user['user_name']}?

{$this->lang->continue}"); } else { $this->db->query('UPDATE logs SET log_user=%d WHERE log_user=%d', USER_GUEST_UID, $this->get['id']); $this->db->query('DELETE FROM users WHERE user_id=%d', $this->get['id']); $user = $this->db->fetch('SELECT user_id, user_name FROM users ORDER BY user_id DESC LIMIT 1'); $counts = $this->db->fetch('SELECT COUNT(user_id) AS count FROM users'); $this->sets['users'] = $counts['count']-1; $this->write_sets(); return $this->message($this->lang->mc_delete, $this->lang->mc_deleted); } break; case 'profile': $this->tree($this->lang->mc_edit); $this->get['id'] = intval($this->get['id']); if (!isset($this->post['submit'])) { $user = $this->db->fetch('SELECT * FROM users WHERE user_id=%d LIMIT 1', $this->get['id']); $out = ''; define('U_IGNORE', 0); define('U_TEXT', 1); define('U_BOOL', 2); define('U_BLOB', 3); define('U_DATE', 4); define('U_TIME', 5); define('U_FLOAT', 6); define('U_INT', 7); define('U_CALLBACK', 8); $cols = array( 'user_name' => array($this->lang->mc_user_name, U_TEXT, 20), 'user_email' => array($this->lang->mc_user_email, U_TEXT, 100), 'user_group' => array($this->lang->mc_user_group, U_CALLBACK, 'list_groups'), 'user_language' => array($this->lang->mc_user_language, U_CALLBACK, 'list_langs'), 'user_skin' => array($this->lang->mc_user_skin, U_CALLBACK, 'list_skins'), 'user_id' => array($this->lang->mc_user_id, U_IGNORE), 'user_created' => array($this->lang->mc_user_created, U_TIME), 'user_lastlogon' => array($this->lang->mc_user_lastlogon, U_TIME) ); foreach ($cols as $var => $data) { if (!isset($user[$var])) { continue; } $val = $user[$var]; if (($var == 'user_signature') || ($var == 'user_email') || ($var == 'user_title')) { $val = $this->format($val, FORMAT_HTMLCHARS); } elseif (($var == 'user_icq') && !$val) { $val = null; } $line = ''; switch ($data[1]) { case U_IGNORE: if (!isset($cols[$var][2])) { $line = $val; } else { if ($val) { $line = $this->lang->yes; } else { $line = $this->lang->no; } } break; case U_TIME: $line = $val ? $this->mbdate( DATE_LONG, $val ) : '-'; break; case U_DATE: $line = $val ? $this->mbdate( DATE_ONLY_LONG, $val ) : '-'; break; case U_BOOL: $line = ''; break; case U_FLOAT: $cols[$var][2] += 3; case U_TEXT: case U_INT: $line = ''; break; case U_BLOB: $line = ''; break; case U_CALLBACK: $line = $this->{$cols[$var][2]}($val); break; default: $line = $val; } $out .= eval($this->template('ADMIN_USER_EDIT')); } return eval($this->template('ADMIN_USER_PROFILE')); } else { $user = $this->db->fetch('SELECT user_name FROM users WHERE user_id=%d LIMIT 1', $this->get['id']); $guest_email = $this->post['user_email']; if ($user['user_name'] != 'Guest' && !$this->validator->validate($guest_email, TYPE_EMAIL)) { return $this->message($this->lang->mc_err_updating, $this->lang->mc_email_invaid); } $user_name = $this->format($this->post['user_name'], FORMAT_HTMLCHARS); $user_group = intval($this->post['user_group']); $user_language = $this->post['user_language']; $user_skin = $this->post['user_skin']; $this->db->query( "UPDATE users SET user_name='%s', user_email='%s', user_group=%d, user_language='%s', user_skin='%s' WHERE user_id=%d", $user_name, $guest_email, $user_group, $user_language, $user_skin, $this->get['id'] ); return $this->message($this->lang->mc_edit, $this->lang->mc_edited); } break; default: return $this->message($this->lang->mc, "{$this->lang->mc_edit}
"); } } function list_groups($val) { $out = "'; } function list_skins($val) { $out = "'; } function list_user_avatar_types($val) { $out = "'; } function list_langs($current) { $out = "'; } } ?>