function LcmExportODS() { // $this->LcmExportObject(); global $author_session; $this->mimetype = 'application/vnd.oasis.opendocument.spreadsheet'; // Create a random temporary directory do { $id = create_random_password(15, time()); $file = 'inc/data/report_' . $author_session['username'] . '_' . $id; // TODO: use LcmDataDir ? } while (!mkdir($file)); $this->dir = $file; if (!mkdir($file . '/META-INF')) { lcm_panic("Could not create dir: {$file}/META-INF. " . $GLOBALS['lcm_errormsg']); } if (!($f = fopen($file . '/META-INF/manifest.xml', 'w'))) { lcm_panic("Could not create META-INF/manifest.xml. " . $GLOBALS['lcm_errormsg']); } $contents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\">\n<manifest:file-entry manifest:media-type=\"application/vnd.oasis.opendocument.spreadsheet\" manifest:full-path=\"/\"/>\n<manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"content.xml\"/>\n<manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"styles.xml\"/>\n<manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"meta.xml\"/>\n</manifest:manifest>\n"; fwrite($f, $contents); fclose($f); // write the 'mimetype' file if (!($f = fopen($this->dir . '/mimetype', 'w'))) { lcm_panic("Could not create 'mimetype' file. " . $GLOBALS['lcm_errormsg']); } fwrite($f, $this->mimetype); fclose($f); // write the meta.xml file $meta = '<?xml version="1.0" encoding="UTF-8"?>' . '<office:document-meta' . ' xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"' . ' xmlns:xlink="http://www.w3.org/1999/xlink"' . ' xmlns:dc="http://purl.org/dc/elements/1.1/"' . ' xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"' . ' xmlns:ooo="http://openoffice.org/2004/office" office:version="1.0">' . '<office:meta>' . '<meta:generator>Legal Case Management ' . $GLOBALS['lcm_version_shown'] . '/' . $GLOBALS['lcm_version'] . '/' . 'db' . $GLOBALS['lcm_db_version'] . '</meta:generator>' . '<meta:creation-date>2006-04-05T19:41:19</meta:creation-date>' . '<dc:date>2006-04-05T19:42:20</dc:date>' . '<dc:language>en-US</dc:language>' . '</office:meta>' . '</office:document-meta>' . "\n"; if (!($f = fopen($this->dir . '/meta.xml', 'w'))) { lcm_panic("Could not create meta.xml. " . $GLOBALS['lcm_errormsg']); } fwrite($f, $meta); fclose($f); }
function user_signup($p_username, $p_email) { # Check to see if signup is allowed if (OFF == config_get('allow_signup')) { return false; } if (empty($p_username) || empty($p_email)) { return false; } $t_password = create_random_password($p_email); if (false === user_create($p_username, $t_password, $p_email)) { return false; } email_signup($p_username, $t_password, $p_email); return true; }
function initialiser_sel() { global $htsalt; $htsalt = '$1$' . create_random_password(); }
function send_registration_by_email() { global $lcm_lang_left; $_SESSION['form_data'] = array(); $_SESSION['errors'] = array(); $kwg_email = get_kwg_from_name('+email_main'); $form_items = array('name_first' => 'person_input_name_first', 'name_last' => 'person_input_name_last', 'email' => 'input_email', 'username' => 'authoredit_input_username'); foreach ($form_items as $field => $trad) { $_SESSION['form_data'][$field] = _request($field); if (!_session($field)) { $_SESSION['errors'][$field] = _Ti($trad) . _T('warning_field_mandatory'); } } if (count($_SESSION['errors'])) { lcm_header("Location: lcm_pass.php?register=yes"); exit; } install_html_start(_T('pass_title_register'), 'login'); // There is a risk that an author changes his e-mail after his account // is created, to the e-mail of another person, and therefore block the // other person from registering. But then.. this would allow the other // person to hijack the account, so it would be a stupid DoS. $query = "SELECT id_of_person, status FROM lcm_contact as c, lcm_author as a\n\t\tWHERE c.id_of_person = a.id_author\n\t\tAND value = '" . _session('email') . "'\n\t\tAND type_person = 'author'\n\t\tAND type_contact = " . $kwg_email['id_group']; $result = lcm_query($query); // Test if the user already exists if ($row = lcm_fetch_array($result)) { $id_author = $row['id_of_person']; $status = $row['status']; // TODO: if status = 'pending for validation by admin', show message if ($status == 'trash') { echo "<br />\n"; echo "<div class='box_error'>" . _T('pass_registration_denied') . "</div>\n"; } else { echo "<br />\n"; echo "<div class=\"box_error\" align=\"{$lcm_lang_left}\">" . _T('pass_warning_already_registered') . "</div>\n"; return; } } // // Send identifiers by e-mail // include_lcm('inc_access'); include_lcm('inc_mail'); $username = get_unique_username(_session('username')); $pass = create_random_password(8, $username); $mdpass = md5($pass); $open_subscription = read_meta("site_open_subscription"); if (!($open_subscription == 'yes' || $open_subscription == 'moderated')) { lcm_panic("Subscriptions not permitted."); } $status = 'waiting'; if ($open_subscription == 'yes') { $status = 'normal'; } lcm_query("INSERT INTO lcm_author (name_first, name_last, username, password, status, date_creation, date_update) " . "VALUES ('" . _session('name_first') . "', '" . _session('name_last') . "', '{$username}', '{$mdpass}', 'normal', NOW(), NOW())"); $id_author = lcm_insert_id('lcm_author', 'id_author'); // Add e-mail to lcm_contact lcm_query("INSERT INTO lcm_contact (type_person, type_contact, id_of_person, value)\n\t\t\tVALUES ('author', " . $kwg_email['id_group'] . ", {$id_author}, '" . _session('email') . "')"); // Prepare the e-mail to send to the user $site_name = _T(read_meta('site_name')); $site_address = read_meta('site_address'); $message = _T('info_greetings') . ",\n\n"; $message .= _T('pass_info_here_info', array('site_name' => $site_name, 'site_address' => $site_address)) . "\n\n"; $message .= "- " . _Ti('login_login') . " {$username}\n"; $message .= "- " . _Ti('login_password') . " {$pass}\n\n"; if ($open_subscription == 'moderated') { $message .= _T('pass_info_moderated') . "\n\n"; } $message .= _T('pass_info_automated_msg') . "\n\n"; if (send_email(_session('email'), "[{$site_name}] " . _T('pass_title_personal_identifier'), $message)) { echo "<p>" . _T('pass_info_identifier_mail') . "</p>\n"; } else { $email_admin = read_meta('email_sysadmin'); echo "<div class=\"box_error\"><p>" . _T('pass_warning_mail_failure', array('email_admin' => $email_admin)) . "</p></div>\n"; } // If moderated, send copy to site admin if ($open_subscription == 'moderated') { $email_admin = read_meta('email_sysadmin'); send_email($email_admin, "[{$site_name}] " . _T('pass_title_personal_identifier'), $message); } }
function show_edit_keywords_form($type_obj, $id_obj, $id_obj_sec = 0) { include_lcm('inc_access'); if (!$GLOBALS['legal_obj'][$type_obj]) { lcm_panic("Invalid object type requested"); } if ($id_obj) { // // Show current keywords (already attached to object) // $current_kws = get_keywords_applied_to($type_obj, $id_obj, $id_obj_sec); $cpt = 0; foreach ($current_kws as $kw) { $kwg = get_kwg_from_id($kw['id_group']); $show_kw_value = false; echo "<tr>\n"; echo "<td>" . "<label for=\"kw_value_{$type_obj}{$cpt}\">" . f_err_star('kwg' . $kwg['id_group']) . _Ti(remove_number_prefix($kwg['title'])) . "</label>" . "<br />(" . _T('keywords_input_policy_' . $kwg['policy']) . ")" . "</td>\n"; echo "<td>"; $kw_for_kwg = get_keywords_in_group_id($kwg['id_group']); if (count($kw_for_kwg)) { echo '<input type="hidden" name="kwg_id_' . $type_obj . '[]" value="' . $kwg['id_group'] . '" />' . "\n"; echo '<input type="hidden" name="kw_entry_' . $type_obj . '[]" value="' . $kw['id_entry'] . '" />' . "\n"; echo '<select id="kw_value_' . $type_obj . $cpt . '" name="kw_value_' . $type_obj . '[]">'; echo '<option value="">' . '' . "</option>\n"; foreach ($kw_for_kwg as $kw1) { if ($kw1['hasvalue'] == 'Y') { $show_kw_value = true; } $sel = ''; if (isset($_SESSION['form_data']['kw_value_' . $type_obj][$cpt]) && $_SESSION['form_data']['kw_value_' . $type_obj][$cpt] == $kw1['id_keyword']) { $sel = ' selected="selected" '; } elseif ($kw1['id_keyword'] == $kw['id_keyword']) { $sel = ' selected="selected" '; } echo '<option value="' . $kw1['id_keyword'] . '"' . $sel . '>' . _T(remove_number_prefix($kw1['title'])) . "</option>\n"; } echo "</select>\n"; } // Check if keyword policy = mandatory, and quantity = one $kwg = get_kwg_from_id($kw['id_group']); if (!($kwg['policy'] == 'mandatory' && $kwg['quantity'] == 'one')) { echo '<label for="kw_del_' . $type_obj . $cpt . '">' . '<img src="images/jimmac/stock_trash-16.png" width="16" height="16" alt="Delete?" title="Delete?" />' . '</label> <input type="checkbox" id="kw_del_' . $type_obj . $cpt . '" name="kw_del_' . $type_obj . $cpt . '"/>'; } if ($show_kw_value) { // Use value if submitted with the form, else use previous one if (isset($_SESSION['form_data']['kw_entryval_' . $type_obj . $cpt])) { $tmp_value = $_SESSION['form_data']['kw_entryval_' . $type_obj . $cpt]; } else { $tmp_value = $kw['value']; } echo "<br />\n"; echo '<input type="text" name="kw_entryval_' . $type_obj . $cpt . '" ' . 'value="' . $tmp_value . '" />' . "\n"; } echo "</td>\n"; echo "</tr>\n"; $cpt++; } } // // New keywords // $kwg_for_case = get_kwg_applicable_for($type_obj, $id_obj, $id_obj_sec); $cpt_kw = 0; foreach ($kwg_for_case as $kwg) { echo "<tr>\n"; echo '<td><label for="new_keyword_' . $type_obj . $cpt_kw . '">' . f_err_star('keyword_' . $type_obj . $cpt_kw) . f_err_star('kwg' . $kwg['id_group']) . _Ti(remove_number_prefix($kwg['title'])) . '</label>' . "<br />(" . _T('keywords_input_policy_' . $kwg['policy']) . ")</td>\n"; echo "<td>"; $kw_for_kwg = get_keywords_in_group_id($kwg['id_group']); if (count($kw_for_kwg)) { $obj_id_ajax = 'kw_' . create_random_password(15, time()); echo '<input type="hidden" name="new_kwg_' . $type_obj . '_id[]" value="' . $kwg['id_group'] . '" />' . "\n"; echo '<select id="new_keyword_' . $type_obj . $cpt_kw . '" ' . 'name="new_keyword_' . $type_obj . '_value[]" ' . "onchange=\"getKeywordInfo('get_kwg_in','" . $kwg['name'] . "', '{$type_obj}', {$id_obj}, 0, '{$obj_id_ajax}')\"" . '>'; echo '<option value="">' . '' . "</option>\n"; $show_kw_value = false; foreach ($kw_for_kwg as $kw) { if ($kw['hasvalue'] == 'Y') { $show_kw_value = true; } // For default value, use the form_data (if present), else use suggested keyword $sel = ''; if (isset($_SESSION['form_data']['new_keyword_' . $type_obj . '_value'][$cpt_kw]) && $_SESSION['form_data']['new_keyword_' . $type_obj . '_value'][$cpt_kw] == $kw['id_keyword']) { $sel = ' selected="selected" '; } elseif ($kwg['suggest'] == $kw['name']) { $sel = ' selected="selected" '; } // $sel = ($kwg['suggest'] == $kw['name'] ? ' selected="selected" ' : ''); echo '<option ' . $sel . ' value="' . $kw['id_keyword'] . '">' . _T(remove_number_prefix($kw['title'])) . "</option>\n"; } echo "</select>\n"; if ($show_kw_value) { $tmp_value = ''; if (isset($_SESSION['form_data']['new_kw_entryval_' . $type_obj . $cpt_kw])) { $tmp_value = $_SESSION['form_data']['new_kw_entryval_' . $type_obj . $cpt_kw]; } echo "<br />\n"; echo '<input type="text" name="new_kw_entryval_' . $type_obj . $cpt_kw . '" ' . 'value="' . $tmp_value . '" />' . "\n"; } echo '<div id="' . $obj_id_ajax . '"></div>' . "\n"; } else { // // Sub-keyword group(s), since no top-level keywords // $sub_kwgs = get_subgroups_in_group_id($kwg['id_group']); if (count($sub_kwgs)) { echo '<input type="hidden" name="nop_kwg_' . $type_obj . '_id[]" value="' . $kwg['id_group'] . '" />' . "\n"; $obj_id_ajax = 'kw_' . create_random_password(15, time()); $sel_id = 'nop_kwg_' . $type_obj . $cpt_kw; $sel_name = 'nop_keyword_' . $type_obj . '_value[]'; echo "<select id=\"{$sel_id}\" name=\"{$sel_name}\" " . "onchange=\"getKeywordInfo('get_kwg_in', this.value, '{$type_obj}', {$id_obj}, 0, '{$obj_id_ajax}')\"" . '>'; echo '<option value="">' . '' . "</option>\n"; foreach ($sub_kwgs as $sg) { echo '<option value="' . $sg['name'] . '">' . _T(remove_number_prefix($sg['title'])) . "</option>\n"; } echo "</select>\n"; echo '<div id="' . $obj_id_ajax . '"></div>' . "\n"; } echo '<div id="keywords_in_group_data' . $kwg['id_group'] . '"></div>' . "\n"; } echo "</td>\n"; echo "</tr>\n"; $cpt_kw++; } }
} echo "</div>\n"; } elseif ($action == 'get_kws_in') { // Searching keywords to add to a case (experimental) include_lcm('inc_keywords'); include_lcm('inc_access'); echo '<div id="' . _request('div') . '">'; $id_obj = _request('id_obj', 0); $type_obj = _request('type_obj', '__ASSERT__'); $group_name = _request('group_name'); if ($group_name) { $kwg = get_kwg_from_name($group_name); $id_group = $kwg['id_group']; $kw_for_kwg = get_keywords_in_group_id($id_group); if (count($kw_for_kwg)) { $obj_id_ajax = 'kw_' . create_random_password(15, time()); echo '<input type="hidden" name="new_kwg_' . $type_obj . '_id[]" value="' . $id_group . '" />' . "\n"; echo '<select id="new_keyword_' . $type_obj . $cpt_kw . '" ' . 'name="new_keyword_' . $type_obj . '_value[]" ' . "onchange=\"getKeywordInfo('get_kwg_in','{$group_name}','{$type_obj}',{$id_obj},0, '{$obj_id_ajax}')\"" . '>'; echo '<option value="">' . '' . "</option>\n"; $show_kw_value = false; foreach ($kw_for_kwg as $kw) { if ($kw['hasvalue'] == 'Y') { $show_kw_value = true; } // For default value, use the form_data (if present), else use suggested keyword if (isset($_SESSION['form_data']['new_keyword_' . $type_obj . '_value'][$cpt_kw]) && $_SESSION['form_data']['new_keyword_' . $type_obj . '_value'][$cpt_kw] == $kw['id_keyword']) { $sel = ' selected="selected" '; } elseif ($kwg['suggest'] == $kw['name']) { $sel = ' selected="selected" '; } else { $sel = '';
function signup_user($p_username, $p_email = false) { global $g_use_ldap_email, $g_mantis_user_table, $g_default_new_account_access_level, $g_mantis_user_pref_table, $g_default_advanced_report, $g_default_advanced_view, $g_default_advanced_update, $g_default_refresh_delay, $g_default_redirect_delay, $g_default_email_on_new, $g_default_email_on_assigned, $g_default_email_on_feedback, $g_default_email_on_resolved, $g_default_email_on_closed, $g_default_email_on_reopened, $g_default_email_on_bugnote, $g_default_email_on_status, $g_default_email_on_priority, $g_default_language; if (false == $p_email && ON == $g_use_ldap_email) { $p_email = get_user_info("{$p_username}", "email"); } $t_seed = $p_email ? $p_email : $p_username; # Create random password $t_password = create_random_password($t_seed); # Use a default access level # create the almost unique string for each user then insert into the table $t_cookie_string = create_cookie_string($t_seed); $t_password2 = process_plain_password($t_password); $query = "INSERT INTO {$g_mantis_user_table}\n\t\t\t\t( id, username, email, password, date_created, last_visit,\n\t\t\t\tenabled, protected, access_level, login_count, cookie_string )\n\t\t\t\tVALUES\n\t\t\t\t( null, '{$p_username}', '{$p_email}', '{$t_password2}', NOW(), NOW(),\n\t\t\t\t1, 0, {$g_default_new_account_access_level}, 0, '{$t_cookie_string}')"; $result = db_query($query); if (!$result) { return false; } # Create preferences for the user $t_user_id = db_insert_id(); $query = "INSERT INTO {$g_mantis_user_pref_table}\n\t\t\t\t(id, user_id, advanced_report, advanced_view, advanced_update,\n\t\t\t\trefresh_delay, redirect_delay,\n\t\t\t\temail_on_new, email_on_assigned,\n\t\t\t\temail_on_feedback, email_on_resolved,\n\t\t\t\temail_on_closed, email_on_reopened,\n\t\t\t\temail_on_bugnote, email_on_status,\n\t\t\t\temail_on_priority, language)\n\t\t\t\tVALUES\n\t\t\t\t(null, '{$t_user_id}', '{$g_default_advanced_report}',\n\t\t\t\t'{$g_default_advanced_view}', '{$g_default_advanced_update}',\n\t\t\t\t'{$g_default_refresh_delay}', '{$g_default_redirect_delay}',\n\t\t\t\t'{$g_default_email_on_new}', '{$g_default_email_on_assigned}',\n\t\t\t\t'{$g_default_email_on_feedback}', '{$g_default_email_on_resolved}',\n\t\t\t\t'{$g_default_email_on_closed}', '{$g_default_email_on_reopened}',\n\t\t\t\t'{$g_default_email_on_bugnote}', '{$g_default_email_on_status}',\n\t\t\t\t'{$g_default_email_on_priority}', '{$g_default_language}')"; $result = db_query($query); if (!$result) { return false; } # Send notification email if ($p_email) { email_signup($t_user_id, $t_password); } return $t_cookie_string; }